Artifact e57d8be90e2157e280934a21738095b2a4275cb2950ceaaeae493ce661b271ea:
- File
src/OFIterator.m
— part of check-in
[2a4aa05a84]
at
2009-05-05 12:05:06
on branch trunk
— Rename OFArray to OFDataArray and add a new OFArray which stores objects.
Additionally, change OFAutoreleasePool to use the new OFArray.And while at it, change #import <config.h> in some files to
#import "config.h". (user: js, size: 1113) [annotate] [blame] [check-ins using]
/* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "config.h" #import "OFIterator.h" #import "OFDictionary.h" #import "OFExceptions.h" @implementation OFIterator - initWithData: (OFList**)data_ andSize: (size_t)size_ { self = [super init]; data = data_; size = size_; pos = 0; last = NULL; return self; } - (id)nextObject { if (last == NULL) { for (; pos < size && data[pos] == nil; pos++); if (pos == size) @throw [OFNotInSetException newWithClass: [OFDictionary class]]; return (last = [data[pos++] first])->object; } if ((last = last->next) != NULL) return last->object; return [self nextObject]; } - reset { pos = 0; last = NULL; return self; } @end @implementation OFDictionary (OFIterator) - (OFIterator*)iterator { return [[[OFIterator alloc] initWithData: data andSize: size] autorelease]; } @end