Zen API
 All Classes Files Functions Variables Typedefs Macros Groups Pages
kCollection Interface Reference

Description

Supports forward iteration over a collection of items.

See also
kIterator

The kCollection interface supports forward iteration over a collection of elements. Typically, the classes that implement this interface provide alternative, class-specific accessor methods with better performance. However, the kCollection interface can be used to reduce the amount of container-specific code required to iterate over a variety of collections, in contexts where performance is not important.

kObject collection = arrayList;
kType type = kCollection_ItemType(collection);
while (kCollection_HasNext(collection, it))
{
void* item = kCollection_Next(collection, &it);
//...
}
+ Inheritance diagram for kCollection:

Public Member Functions

kSize kCollection_Count (kCollection collection)
 Gets the collection element count. More...
 
kIterator kCollection_GetIterator (kCollection collection)
 Returns an iterator to the first element in the collection. More...
 
kBool kCollection_HasNext (kCollection collection, kIterator iterator)
 Determines whether a collection has another item. More...
 
kType kCollection_ItemType (kCollection collection)
 Gets the collection element type. More...
 
void * kCollection_Next (kCollection collection, kIterator *iterator)
 Gets the next collection element and then advances the iterator. More...
 

Member Function Documentation

kSize kCollection_Count ( kCollection  collection)

Gets the collection element count.

Parameters
collectionCollection object.
Returns
Item count.
kIterator kCollection_GetIterator ( kCollection  collection)

Returns an iterator to the first element in the collection.

Parameters
collectionCollection object.
Returns
Iterator.
kBool kCollection_HasNext ( kCollection  collection,
kIterator  iterator 
)

Determines whether a collection has another item.

Parameters
collectionCollection object.
iteratorCollection iterator.
Returns
kTRUE if the collection has a next element.
kType kCollection_ItemType ( kCollection  collection)

Gets the collection element type.

Parameters
collectionCollection object.
Returns
Item type.
void * kCollection_Next ( kCollection  collection,
kIterator iterator 
)

Gets the next collection element and then advances the iterator.

Parameters
collectionCollection object.
iteratorPointer to collection iterator.
Returns
Pointer to next collection element.

The documentation for this interface was generated from the following file: