Contents

initWithCapacity

Initializes a new instance of OSOrderedSet.

Declaration

virtual bool initWithCapacity( 
 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

true on success, false on failure.

Overview

Not for general use. Use the static instance creation method withCapacity instead.

capacity must be nonzero. The new set 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