Class: TCollectionOf

Declaration: CollectionOf.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

MCollectible

Inherited By:

TPriorityQueueOf TSequenceOf TSetOf

Purpose:

TCollectionOf is the abstract base class of several collection classes. These collection classes hold objects of a type you define. TCollectionOf provides a common protocol for adding, removing, counting and querying.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

Do not derive any classes from TCollectionOf.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Other Considerations:

Objects in this collection must all be of the type specified in the template parameter. When using the DeleteAll operator, be aware that you are responsible for ensuring that none of the objects in the collection have been allocated on the stack and that none of the objects are referenced by any other data structures.

Member Function: TCollectionOf::~TCollectionOf

virtual ~ TCollectionOf ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Call this function directly to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::Add

AType * Add (const AType * obj)

Interface Category:

API.

Purpose:

Adds an object to the collection.

Calling Context:

Used to add an object. Call this function directly.

Parameters:

Return Value:

A pointer to the added object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::Member

AType * Member (const AType & obj) const

Interface Category:

API.

Purpose:

Determines if an object is in the collection.

Calling Context:

Searches the collection to determine if the object you have specified is in the collection. Call this function directly.

Parameters:

Return Value:

A reference to the object, if the object is in the collection. A NIL reference is returned if the object is not found.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::Remove

AType * Remove (const AType & obj)

Interface Category:

API.

Purpose:

Removes an object from the collection.

Calling Context:

Call this function directly to remove an object from the collection. The object's destructor is not called.

Parameters:

Return Value:

A reference to the object, if the object was found in the collection. A NIL reference is returned if the object was not found.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::RemoveAll

void RemoveAll ()

Interface Category:

API.

Purpose:

Removes all objects from the collection.

Calling Context:

Call this function directly to remove all objects from the collection. Destructors for all the removed objects are not called.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::IsEmpty

bool IsEmpty () const

Interface Category:

API.

Purpose:

Determines if the collection is empty.

Calling Context:

Call this function directly to determine if the collection is empty.

Parameters:

Return Value:

Returns true if the collection is empty.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::Count

CollectionCount Count () const

Interface Category:

API.

Purpose:

Counts the number of objects in the collection.

Calling Context:

Call this function directly to count the number of objects in the collection.

Parameters:

Return Value:

Number of objects in the collection.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::AddCollection

void AddCollection (const TCollectionOf < AType > * col)

Interface Category:

API.

Purpose:

Adds all the objects from another collection to this collection.

Calling Context:

Call this function directly to add all the objects from another collection to this collection.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

The objects from the other collection are not removed from that collection. They are effectively aliased to this collection.

Member Function: TCollectionOf::CreateIterator

TIteratorOver < AType > * CreateIterator () const

Interface Category:

API.

Purpose:

Creates an iterator for this collection.

Calling Context:

Call this function directly to create an iterator for this collection.

Parameters:

Return Value:

A reference to the iterator created for this collection.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::Hash

virtual CollectionHash Hash () const

Interface Category:

API.

Purpose:

Returns the hash value for the collection.

Calling Context:

This is a required override for every MCollectible derived class. Call this function directly.

Parameters:

Return Value:

Returns the hash value for the collection.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::operator>>=

TStream & operator >>=(TStream & towhere) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Call this function directly to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::operator<<=

TStream & operator <<= (TStream & fromwhere)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Call this function directly to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::operator==

bool operator ==(const TCollectionOf < AType > & collectionOf) const

Interface Category:

API.

Purpose:

Compares this collection with another collection of the same type.

Calling Context:

Call this function directly to compare this collection with another collection of the same type.

Parameters:

Return Value:

Returns true if this collection contains the same count as the other collection and if every object in this collection has a corresponding object in the other collection that is equivalent.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::operator!=

bool operator != (const TCollectionOf < AType > & collectionOf) const

Interface Category:

API.

Purpose:

Compares this collection with another collection of the same type.

Calling Context:

Call this function directly to determine if this collection is not equal to another collection.

Parameters:

Return Value:

Returns true if this collection contains a different count when compared to another collection or if one or more objects in this collection do not have an equivalent, corresponding object in the other collection.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::TCollectionOf

  1. TCollectionOf ()
  2. TCollectionOf (const TCollectionOf < AType > & that)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Copy constructor.

Calling Context:

  1. Call this function directly by the stream-in operators and any other time that creation of an empty TCollectionOf is desired.
  2. Call this function directly to create a TCollectionOf initialized to the contents of the specified collection.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Calling the copy constructor with a NIL reference has the same result as calling the default constructor.

Member Function: TCollectionOf::operator=

const TCollectionOf < AType > & operator =(const TCollectionOf < AType > & thatObj)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Call this function directly when an object is assigned to another compatible object.

Parameters:

Return Value:

A reference to the left-hand object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TCollectionOf::DeleteAll

void DeleteAll ()

Interface Category:

API

Purpose:

Deletes all objects from the collection, calling each object's destructor in the process.

Calling Context:

Call this function directly to delete the object from the collection.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.