63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
-
+
|
}
- (size_t)itemsize
{
return itemsize;
}
- (void*)data
- (void*)cArray
{
return data;
}
- (void*)itemAtIndex: (size_t)index
{
if (index >= count)
|
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
-
-
+
+
|
withSize: itemsize];
memcpy(data + count++ * itemsize, item, itemsize);
return self;
}
- addNItems: (size_t)nitems
fromCArray: (void*)carray
- addNItems: (size_t)nitems
fromCArray: (void*)carray
{
if (nitems > SIZE_MAX - count)
@throw [OFOutOfRangeException newWithClass: isa];
data = [self resizeMemory: data
toNItems: count + nitems
withSize: itemsize];
|
143
144
145
146
147
148
149
150
151
152
153
154
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
|
143
144
145
146
147
148
149
150
151
152
153
154
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
|
-
+
-
+
-
+
-
+
|
- (BOOL)isEqual: (id)obj
{
if (![obj isKindOfClass: [OFDataArray class]])
return NO;
if ([obj count] != count || [obj itemsize] != itemsize)
return NO;
if (memcmp([obj data], data, count * itemsize))
if (memcmp([obj cArray], data, count * itemsize))
return NO;
return YES;
}
- (int)compare: (id)obj
{
int ret;
if (![obj isKindOfClass: [OFDataArray class]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
if ([obj itemsize] != itemsize)
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
if ([obj count] == count)
return memcmp(data, [obj data], count * itemsize);
return memcmp(data, [obj cArray], count * itemsize);
if (count > [obj count]) {
if ((ret = memcmp(data, [obj data], [obj count] * itemsize)))
if ((ret = memcmp(data, [obj cArray], [obj count] * itemsize)))
return ret;
return *(char*)[self itemAtIndex: [obj count]];
} else {
if ((ret = memcmp(data, [obj data], count * itemsize)))
if ((ret = memcmp(data, [obj cArray], count * itemsize)))
return ret;
return *(char*)[obj itemAtIndex: count] * -1;
}
}
- (uint32_t)hash
|