Inherits From:
Declared In:

Class Description

NSArrays do not allow "gaps" between the objects. This can be worked around with a dedicated marker object for empty positions but when these gaps become large storage and the count operation become inefficient. EDSparseClusterArray solves these problems to a certain extent. It works well when larger groups of objects, i.e. a few hundred objects, are separated by few small gaps and these groups (or clusters) are separated by arbitrarily large gaps. Hence the name EDSparseClusterArray.

Instance Variables

NSMapTable *pageTable;
unsigned int pageSize;

pageTableAll instance variables are private.

Method Types

Creating sparse cluster arrays
- init
Adding and removing objects
- setObject:atIndex:
- removeObjectAtIndex:
- objectAtIndex:
Querying the array
- count
- indexEnumerator
- allObjects

Instance Methods


- (NSArray *)allObjects

Returns an array containing the receiver's objects, or an empty array if the receiver has no objects. The order of the objects in the array is the same as in the receiver.


- (unsigned int)count

Returns the number of objects in the receiver.


- (NSEnumerator *)indexEnumerator

Returns an enumerator object that lets you access all indeces for occupied slots in the receiver, in order, starting with the smallest index. You should not modify the receiver while using the enumerator. For a more detailed explanation and sample code see the description of keyEnumerator in NSDictionary.


- (id)init

Initialises a newly allocated sparse cluster array.


- (id)objectAtIndex:(unsigned int)index

Returns the object located at index, or nil if the slot was empty.


- (void)removeObjectAtIndex:(unsigned int)index

Removes the object stored in slot index from the receiver. The object receives a release message.

This method raises an NSInvalidArgumentException if the slot was empty.


- (void)setObject:(id)anObject atIndex:(unsigned int)index

Stores anObject in the slot index of the receiver. Index can be arbitrarily large without affecting performance. The object receives a retain message.

If the slot is already occupied, the object at the index is removed and receives a release message.

This method raises an NSInvalidArgumentException if anObject is nil.

Version 2.0 Copyright ©2002. All Rights Reserved.