ADC Home > Reference Library > Reference > Darwin > Kernel Framework Reference

 


OSOrderedSet

Inherits from:
Declared In:

Overview

A collection class for maintaining and sorting a set of OSMetaClassBase-derived objects.

Discussion

An instance of OSOrderedSet maintains and sorts a collection of OSMetaClassBase-derived objects. The sorting algorithm is supplied to the instance via the OSOrderFunction.



Functions

containsObject

Queries the set for the presence of the specified object.

ensureCapacity

Expands the size of the collection.

flushCollection

Removes and releases all items in the set.

free

Releases and deallocates any resources used by the instance of OSOrderedSet.

getCapacity

Returns the storage capacity of the collection.

getCapacityIncrement

Gets the size by which the collection will grow.

getCount

Returns the number of objects within the collection.

getFirstObject

Returns the first object in the set.

getLastObject

Returns the last object in the set.

getObject

Returns a reference to an object at the specified index.

getOrderingRef

Returns the ordering context.

initWithCapacity

Initializes an instance of OSOrderedSet.

isEqualTo(const OSMetaClassBase *)

Tests the equality between an arbitrary OSMetaClassBase-derived object and the receiver.

isEqualTo(const OSOrderedSet *)

Tests the equality between an OSOrderedSet object and the receiver.

member

Queries the set for the presence of the specified object.

orderObject

Returns the ordering value of the specified object.

removeObject

Removes and releases an object in the set.

setCapacityIncrement

Sets the size by which the collection will grow.

setFirstObject

Places an OSMetaClassBase-derived object into the first position in the set.

setLastObject

Places an OSMetaClassBase-derived object into the last position in the set.

setObject(const OSMetaClassBase *)

Places an OSMetaClassBase-derived object into the set.

setObject(unsigned int, const OSMetaClassBase *)

Places the specified object into the set at the specified index.

withCapacity

Creates and initializes an instance of OSOrderedSet.


containsObject


Queries the set for the presence of the specified object.

public

virtual bool containsObject( const OSMetaClassBase *anObject) const;
Parameters
anObject

The object to be located.

Return Value

Returns true if the object is present in the set, false otherwise.


ensureCapacity


Expands the size of the collection.

public

virtual unsigned int ensureCapacity( unsigned int newCapacity);
Parameters
newCapacity

The new size capacity for the collection.

Return Value

Returns the new capacity of the set when successful or the old capacity on failure.


flushCollection


Removes and releases all items in the set.

public

virtual void flushCollection();


free


Releases and deallocates any resources used by the instance of OSOrderedSet.

public

virtual void free();


getCapacity


Returns the storage capacity of the collection.

public

virtual unsigned int getCapacity() const;
Return Value

Returns the total storage capacity of the set.


getCapacityIncrement


Gets the size by which the collection will grow.

public

virtual unsigned int getCapacityIncrement() const;
Return Value

Returns the current growth size.


getCount


Returns the number of objects within the collection.

public

virtual unsigned int getCount() const;
Return Value

Returns the number of items in the set.


getFirstObject


Returns the first object in the set.

public

virtual OSObject *getFirstObject() const;
Return Value

Returns the object ordered first in the set or 0 if none exist.


getLastObject


Returns the last object in the set.

public

virtual OSObject *getLastObject() const;
Return Value

Returns the object ordered last in the set or 0 if none exist.


getObject


Returns a reference to an object at the specified index.

public

virtual OSObject *getObject( unsigned int index) const;
Parameters
index

The index into the set.

Return Value

Returns a reference to the object at the given index, 0 if none exist at that location.


getOrderingRef


Returns the ordering context.

public

virtual void *getOrderingRef();
Return Value

Returns the ordering context, or NULL if none exist.


initWithCapacity


Initializes an instance of OSOrderedSet.

public

virtual bool initWithCapacity( unsigned int capacity, OSOrderFunction orderFunc = 0, void *orderingRef = 0);
Parameters
capacity

The initial storage size in number of objects of the set.

orderFunc

A C-style function that implements the sorting algorithm for the set.

orderingRef

An ordering context used as a hint for ordering objects within the set.

Return Value

Returns true if initialization was successful, or false if a failure occurred.


isEqualTo(const OSMetaClassBase *)


Tests the equality between an arbitrary OSMetaClassBase-derived object and the receiver.

public

virtual bool isEqualTo( const OSMetaClassBase *anObject) const;
Parameters
anObject

The OSMetaClassBase-derived object to be compared against the receiver.

Return Value

Returns true if the two objects are equivalent, false otherwise.


isEqualTo(const OSOrderedSet *)


Tests the equality between an OSOrderedSet object and the receiver.

public

virtual bool isEqualTo( const OSOrderedSet *anOrderedSet) const;
Parameters
anOrderedSet

The OSOrderedSet object to be compared against the receiver.

Return Value

Returns true if the two objects are equivalent, false otherwise.


member


Queries the set for the presence of the specified object.

public

virtual bool member( const OSMetaClassBase *anObject) const;
Parameters
anObject

The object to be located.

Return Value

Returns true if the object is present in the set, false otherwise.


orderObject


Returns the ordering value of the specified object.

public

virtual SInt32 orderObject( const OSMetaClassBase * anObject );
Parameters
anObject

The object to be queried.

Return Value

Returns the ordering value for an object.


removeObject


Removes and releases an object in the set.

public

virtual void removeObject( const OSMetaClassBase *anObject);
Parameters
anObject

The object to remove from the set.


setCapacityIncrement


Sets the size by which the collection will grow.

public

virtual unsigned int setCapacityIncrement( unsigned increment);
Parameters
increment

The new growth factor for the set.

Return Value

Returns the new growth size.


setFirstObject


Places an OSMetaClassBase-derived object into the first position in the set.

public

virtual bool setFirstObject( const OSMetaClassBase *anObject);
Parameters
anObject

The object to be placed into the collection.

Return Value

Returns true if the object was successfully added to the collection, false otherwise.


setLastObject


Places an OSMetaClassBase-derived object into the last position in the set.

public

virtual bool setLastObject( const OSMetaClassBase *anObject);
Parameters
anObject

The object to be placed into the collection.

Return Value

Returns true if the object was successfully added to the collection, false otherwise.


setObject(const OSMetaClassBase *)


Places an OSMetaClassBase-derived object into the set.

public

virtual bool setObject( const OSMetaClassBase *anObject);
Parameters
anObject

The object to be placed into the collection.

Return Value

Returns true if the object was successfully added to the collection, false otherwise.

Discussion

Note that the object will be automatically sorted in the set.


setObject(unsigned int, const OSMetaClassBase *)


Places the specified object into the set at the specified index.

public

virtual bool setObject( unsigned int index, const OSMetaClassBase *anObject);
Parameters
index

The index in the set to place the object.

anObject

The object to be placed into the set.

Return Value

Returns true if the object was successfully placed into the collection, false otherwise.


withCapacity


Creates and initializes an instance of OSOrderedSet.

public

static OSOrderedSet *withCapacity( unsigned int capacity, OSOrderFunction orderFunc = 0, void *orderingRef = 0);
Parameters
capacity

The initial storage size in number of objects of the set.

orderFunc

A C-style function that implements the sorting algorithm for the set.

orderingRef

An ordering context used as a hint for ordering objects within the set.

Return Value

Returns an instance of OSOrderedSet, or 0 if a failure occurred.

Typedefs


OSOrderFunction


The sorting function used by the collection to order objects.

public

typedef SInt32 ( *OSOrderFunction)( const OSMetaClassBase * obj1, const OSMetaClassBase * obj2, void * ref );
Parameters
obj1

An object from the collection.

obj2

An object to be compared to obj1.

ref

The ordering context used by the sorting function as a hint for sorting.

Return Value

Returns a comparison result of the object, a negative value if obj1 > obj2, 0 if obj1 == obj2, and a positive value if obj1

Member Data


reserved


protected

ExpansionData *reserved;
Discussion

Reserved for future use. (Internal use only)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.

 

Last Updated: 2008-12-19