Differences From Artifact [0b15af59f1]:
- File
src/OFArray.m
— part of check-in
[7feac9e596]
at
2009-01-24 20:28:31
on branch trunk
— [self alloc] isn't a good idea with the new API.
The reason is that a derived class, for example derived from OFArray,
would not return an OFArray when + arrayWithItemSize is called. (user: js, size: 3480) [annotate] [blame] [check-ins using]
To Artifact [99432f285e]:
- File
src/OFArray.m
— part of check-in
[61a6ac873a]
at
2009-02-14 17:08:21
on branch trunk
— Big diff, see details.
* Add OFComparable protocol.
* Add OFInvalidArgument exception - needs that sel_getName vs.
sel_get_name stuff again, therefore reintroduce it.
* Implement proper copy method for OFString and OFArray.
* Add isEqual: and compare: for OFString and OFArray. (user: js, size: 4645) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
112 113 114 115 116 117 118 119 120 121 122 123 124 125 | toNItems: items - nitems ofSize: itemsize]; items -= nitems; return self; } @end @implementation OFBigArray - initWithItemSize: (size_t)is { if (lastpagebyte == 0) lastpagebyte = getpagesize() - 1; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 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 | toNItems: items - nitems ofSize: itemsize]; items -= nitems; return self; } - (id)copy { OFArray *new = [OFArray arrayWithItemSize: itemsize]; [new addNItems: items fromCArray: data]; return new; } - (BOOL)isEqual: (id)obj { if (![obj isKindOf: [OFArray class]]) return NO; if ([obj items] != items || [obj itemsize] != itemsize) return NO; if (memcmp([obj data], data, items * itemsize)) return NO; return YES; } - (int)compare: (id)obj { int ret; if (![obj isKindOf: [OFArray class]]) @throw [OFInvalidArgumentException newWithClass: [self class] andSelector: _cmd]; if ([obj itemsize] != itemsize) @throw [OFInvalidArgumentException newWithClass: [self class] andSelector: _cmd]; if ([obj items] == items) return memcmp(data, [obj data], items * itemsize); if (items > [obj items]) { if ((ret = memcmp(data, [obj data], [obj items] * itemsize))) return ret; return *(char*)[self item: [obj items]]; } else { if ((ret = memcmp(data, [obj data], items * itemsize))) return ret; return *(char*)[obj item: [self items]] * -1; } } @end @implementation OFBigArray - initWithItemSize: (size_t)is { if (lastpagebyte == 0) lastpagebyte = getpagesize() - 1; |
︙ | ︙ | |||
184 185 186 187 188 189 190 191 | toSize: nsize]; items -= nitems; size = nsize; return self; } @end | > > > > > > > > > > | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | toSize: nsize]; items -= nitems; size = nsize; return self; } - (id)copy { OFArray *new = [OFArray bigArrayWithItemSize: itemsize]; [new addNItems: items fromCArray: data]; return new; } @end |