Differences From Artifact [99a256af1a]:
- File
src/OFList.m
— part of check-in
[2a27cf3000]
at
2016-01-03 00:41:26
on branch trunk
— Update copyright
While at it, also update the mail address. (user: js, size: 9260) [annotate] [blame] [check-ins using]
To Artifact [809ddd51dc]:
- File src/OFList.m — part of check-in [e0b9167693] at 2016-02-21 15:37:42 on branch trunk — Make use of C99-style for loops (user: js, size: 9246) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
63 64 65 66 67 68 69 | } return self; } - (void)dealloc { | | < | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | } return self; } - (void)dealloc { for (of_list_object_t *iter = _firstListObject; iter != NULL; iter = iter->next) [iter->object release]; [super dealloc]; } - (of_list_object_t*)appendObject: (id)object { |
︙ | ︙ | |||
225 226 227 228 229 230 231 | assert(iter == NULL && iter2 == NULL); return true; } - (bool)containsObject: (id)object { | < < > | < < > | | 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | assert(iter == NULL && iter2 == NULL); return true; } - (bool)containsObject: (id)object { if (_count == 0) return false; for (of_list_object_t *iter = _firstListObject; iter != NULL; iter = iter->next) if ([iter->object isEqual: object]) return true; return false; } - (bool)containsObjectIdenticalTo: (id)object { if (_count == 0) return false; for (of_list_object_t *iter = _firstListObject; iter != NULL; iter = iter->next) if (iter->object == object) return true; return false; } - (void)removeAllObjects |
︙ | ︙ | |||
270 271 272 273 274 275 276 | _firstListObject = _lastListObject = NULL; } - copy { OFList *copy = [[[self class] alloc] init]; | | > | | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | _firstListObject = _lastListObject = NULL; } - copy { OFList *copy = [[[self class] alloc] init]; of_list_object_t *listObject, *previous; listObject = NULL; previous = NULL; @try { for (of_list_object_t *iter = _firstListObject; iter != NULL; iter = iter->next) { listObject = [copy allocMemoryWithSize: sizeof(of_list_object_t)]; listObject->object = [iter->object retain]; listObject->next = NULL; listObject->previous = previous; if (copy->_firstListObject == NULL) |
︙ | ︙ | |||
304 305 306 307 308 309 310 | copy->_lastListObject = listObject; return copy; } - (uint32_t)hash { | < > | < > | | < < | | > | < | | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | copy->_lastListObject = listObject; return copy; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); for (of_list_object_t *iter = _firstListObject; iter != NULL; iter = iter->next) OF_HASH_ADD_HASH(hash, [iter->object hash]); OF_HASH_FINALIZE(hash); return hash; } - (OFString*)description { OFMutableString *ret; if (_count == 0) return @"[]"; ret = [OFMutableString stringWithString: @"[\n"]; for (of_list_object_t *iter = _firstListObject; iter != NULL; iter = iter->next) { void *pool = objc_autoreleasePoolPush(); [ret appendString: [iter->object description]]; if (iter->next != NULL) [ret appendString: @",\n"]; objc_autoreleasePoolPop(pool); } [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @"\n]"]; [ret makeImmutable]; return ret; } - (OFXMLElement*)XMLElementBySerializing { OFXMLElement *element = [OFXMLElement elementWithName: [self className] namespace: OF_SERIALIZATION_NS]; for (of_list_object_t *iter = _firstListObject; iter != NULL; iter = iter->next) { void *pool = objc_autoreleasePoolPush(); [element addChild: [iter->object XMLElementBySerializing]]; objc_autoreleasePoolPop(pool); } return element; } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count { of_list_object_t *listObject; memcpy(&listObject, state->extra, sizeof(listObject)); state->itemsPtr = objects; state->mutationsPtr = &_mutations; if (state->state == 0) { listObject = _firstListObject; state->state = 1; } for (int i = 0; i < count; i++) { if (listObject == NULL) return i; objects[i] = listObject->object; listObject = listObject->next; } |
︙ | ︙ |