withCapacity
Creates and initializes an empty OSOrderedSet.
Declaration
static OSOrderedSet * withCapacity(
unsigned int capacity,
OSOrderFunction orderFunc = 0,
void *orderingContext = 0);Parameters
- capacity:
The initial storage capacity of the new ordered set object.
- orderFunc:
A C function that implements the sorting algorithm for the set.
- orderingContext:
An ordering context, which is passed to
orderFunc.
Return Value
An empty instance of OSOrderedSet with a retain count of 1; NULL on failure.
Overview
capacity must be nonzero. The new OSOrderedSet will grow as needed to accommodate more key/object pairs (unlike Core Foundation collections, for which the initial capacity is a hard limit).
If orderFunc is provided, it is used by setObject(const OSMetaClassBase *) to determine where to insert a new object. Other object-setting functions ignore ordering.
orderingContext is not retained or otherwise memory-managed by the ordered set. If it needs to be deallocated, you must track references to it and the ordered set in order to deallocate it appropriately. See getOrderingRef.
See Also
Miscellaneous
containsObjectcopyCollectionensureCapacityflushCollectionfreegetCapacitygetCapacityIncrementgetCountgetFirstObjectgetLastObjectgetObjectgetOrderingRefinitWithCapacityisEqualTo(const OSMetaClassBase *)isEqualTo(const OSOrderedSet *)memberorderObjectremoveObjectsetCapacityIncrementsetFirstObjectsetLastObjectsetObject(const OSMetaClassBase *)setObject(unsigned int, const OSMetaClassBase *)