OLArrayIterator Class Reference
[Iterators]

An iterator that can traverse arrays of objects. More...

#import <ObjectiveLib/Iterator.h>

Inheritance diagram for OLArrayIterator:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(id) - advance
 Advance the iterator.
(id) - advanceBy:
 Advance or reverse the iterator by a given number of positions.
(id) - assign:
 Assign an object to the position in the controlled sequence to which this iterator refers.
(id) - copyWithZone:
 Make a copy of this iterator allocating memory from zone.
(id) - dereference
 Dereference the iterator.
(int) - difference:
 Compute the number of positions that lie between this iterator and another one.
(BOOL) - isEqual:
 Return whether this object is equal to another one.
(id) - reverse
 Reverse the iterator by one position.
Initializers and Deallocators
(id) - initWithPointer:
 Initialize the iterator with the given pointer.

Static Public Member Functions

(OLPair *) + pairWithPointer:andPointer:
 Return a pair of array iterators.
(OLPair *) + pairWithPointer:distance:
 Return a pair of array iterators.

Protected Attributes

id * current
 The object to which this iterator currently points.

Detailed Description

An iterator that can traverse arrays of objects.

This is a random access iterator that can be used to traverse arbitrary arrays of ids.

See also:
OLVector


Member Function Documentation

- (id) advance  

Advance the iterator.

After advancing the iterator will point to a position in the container one step beyond the previous position.

Returns:
a reference to this iterator

Reimplemented from OLForwardIterator.

- (id) advanceBy: (int)  count  

Advance or reverse the iterator by a given number of positions.

Parameters:
count the number of positions to move the iterator, either forward or backward
Returns:
a reference to this iterator

Reimplemented from OLRandomAccessIterator.

- (id) assign: (id)  object  

Assign an object to the position in the controlled sequence to which this iterator refers.

The object currently at the position will be removed and replaced with the given object.

Parameters:
object the object to assign
Returns:
a reference to this iterator

Reimplemented from OLIterator.

- (id) copyWithZone: (NSZone *)  zone  

Make a copy of this iterator allocating memory from zone.

Parameters:
zone the zone from which to allocate memory
Returns:
a copy of this iterator

Reimplemented from OLIterator.

- (id) dereference  

Dereference the iterator.

Return the id of the object to which this iterator points.

Returns:
the id of the referenced object

Reimplemented from OLIterator.

- (int) difference: (OLRandomAccessIterator *)  other  

Compute the number of positions that lie between this iterator and another one.

If other is after this iterator in the collection, the result will be negative, otherwise the result will be greater than or equal to zero..

Precondition:
Both iterators must refer to the same collection.
Parameters:
other the iterator for which to compute the distance from this one
Returns:
the number of positions that lie between this iterator and the other one

Reimplemented from OLRandomAccessIterator.

- (id) initWithPointer: (id *)  ptr  

Initialize the iterator with the given pointer.

The iterator will not attempt to take ownership of the pointer, as iterators never own the objects to which they point.

Parameters:
ptr the pointer at the beginning of the array
Returns:
a reference to this iterator

- (BOOL) isEqual: (id)  object  

Return whether this object is equal to another one.

Parameters:
object the object to test
Returns:
YES if the iterator is equal to the object, NO if not

Reimplemented from OLIterator.

+ (OLPair*) pairWithPointer: (id *)  p1
andPointer: (id *)  p2 

Return a pair of array iterators.

Parameters:
p1 the first pointer in the range covered by the pair
p2 the second pointer in the range covered by the pair
Returns:
a pair of iterators covering the given range

+ (OLPair*) pairWithPointer: (id *)  p
distance: (unsigned)  count 

Return a pair of array iterators.

Parameters:
p the pointer at the beginning of the desired range
count the number of objects that should be included in the range
Returns:
a pair of iterators covering the given range

- (id) reverse  

Reverse the iterator by one position.

After reversing the iterator will point to a position in the container one step before the previous position.

Returns:
a reference to this iterator

Reimplemented from OLBidirectionalIterator.


Member Data Documentation

- (id*) current [protected]

The object to which this iterator currently points.


The documentation for this class was generated from the following file:
ObjectiveLibGenerated Sun Apr 22 15:12:48 2007, © 2004-2007 Will Mason
SourceForge.net Logo