Zen API

- Home
- Help Topics
- Types by Category
- All Types
- Files

All Classes Files Functions Variables Typedefs Macros Groups Pages
Public Member Functions
kCollection Interface Reference
kApi/Data

## 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;
kIterator it = kCollection_GetIterator(collection);
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

  collection | Collection object.

Returns
  Item count.

kIterator kCollection_GetIterator | ( | kCollection | collection | ) |

Returns an iterator to the first element in the collection.

Parameters

  collection | Collection object.

Returns
  Iterator.

kBool kCollection_HasNext | ( | kCollection | collection,
|  | kIterator | iterator
| ) |  |

Determines whether a collection has another item.

Parameters

  collection | Collection object.
  iterator | Collection iterator.

Returns
  kTRUE if the collection has a next element.

kType kCollection_ItemType | ( | kCollection | collection | ) |

Gets the collection element type.

Parameters

  collection | Collection object.

Returns
  Item type.

void * kCollection_Next | ( | kCollection | collection,
|  | kIterator * | iterator
| ) |  |

Gets the next collection element and then advances the iterator.

Parameters

  collection | Collection object.
  iterator | Pointer to collection iterator.

Returns
  Pointer to next collection element.

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

- Data/kCollection.h