ObjFW  Check-in [ef368d182c]

Overview
Comment:Add -[setDimension:] to OFFloatVector.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ef368d182c641e23ce69fc29c265d502fc1b6f1e0168041c5020b87d43aacbc7
User & Date: js on 2011-06-16 02:25:01
Other Links: manifest | tags
Context
2011-06-16
02:33
-[readNBytes:intoBuffer:] & -[writeNBytes:fromBuffer:] take a void* now. check-in: 8440a70457 user: js tags: trunk
02:25
Add -[setDimension:] to OFFloatVector. check-in: ef368d182c user: js tags: trunk
02:14
Add -[rotateWithVector:angle:] to OFFloatMatrix. check-in: 91f446cfd8 user: js tags: trunk
Changes

Modified src/OFFloatVector.h from [dc5b2c9055] to [ad6509aa39].

92
93
94
95
96
97
98










99
100
101
102
103
104
105
/**
 * \brief Returns the dimension of the vector.
 *
 * \return The dimension of the vector
 */
- (size_t)dimension;











/**
 * \brief Returns an array of floats with the contents of the vector.
 *
 * Modifying the returned array directly is allowed and will change the vector.
 *
 * \return An array of floats with the contents of the vector
 */







>
>
>
>
>
>
>
>
>
>







92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
 * \brief Returns the dimension of the vector.
 *
 * \return The dimension of the vector
 */
- (size_t)dimension;

/**
 * \brief Changes the dimension of the vector.
 *
 * If the new dimension is smaller, elements will be cut off.
 * If the new dimension is bigger, new elements will be filled with zeros.
 *
 * \param dimension The new dimension for the vector
 */
- (void)setDimension: (size_t)dimension;

/**
 * \brief Returns an array of floats with the contents of the vector.
 *
 * Modifying the returned array directly is allowed and will change the vector.
 *
 * \return An array of floats with the contents of the vector
 */

Modified src/OFFloatVector.m from [a58504ec6e] to [7be4d41cc6].

155
156
157
158
159
160
161


















162
163
164
165
166
167
168
	return data[index];
}

- (size_t)dimension
{
	return dimension;
}



















- (BOOL)isEqual: (id)object
{
	OFFloatVector *otherVector;

	if (![object isKindOfClass: [OFFloatVector class]])
		return NO;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
	return data[index];
}

- (size_t)dimension
{
	return dimension;
}

- (void)setDimension: (size_t)dimension_
{
	float *newData;
	size_t i;

	if ((newData = realloc(data, dimension_ * sizeof(float))) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: dimension_ *
							     sizeof(float)];

	data = newData;

	for (i = dimension; i < dimension_; i++)
		data[i] = 0;

	dimension = dimension_;
}

- (BOOL)isEqual: (id)object
{
	OFFloatVector *otherVector;

	if (![object isKindOfClass: [OFFloatVector class]])
		return NO;