Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

PCollection Class Reference

#include <contain.h>

Inheritance diagram for PCollection:

PContainer PObject PAbstractList PAbstractSortedList PArrayObjects PHashTable PAbstractDictionary PAbstractSet

List of all members.


Detailed Description

A collection is a container that collects together descendents of the PObject# class. The objects contained in the collection are always pointers to objects, not the objects themselves. The life of an object in the collection should be carefully considered. Typically, it is allocated by the user of the collection when it is added. The collection then automatically deletes it when it is removed or the collection is destroyed, ie when the container class has no more references to the collection. Other models may be accommodated but it is up to the programmer to determine the scope and life of the objects.

The exact form of the collection depends on the descendent of PCollection and determines the access modes for the objects in it. Thus a collection can be an array which allows fast random access at the expense of slow insertion and deletion. Or the collection may be a list which has fast insertion and deletion but very slow random access.

The basic paradigm of all collections is the "virtual array". Regardless of the internal implementation of the collection; array, list, sorted list etc, the user may access elements via an ordinal index. The implementation then optimises the access as best it can. For instance, in a list ordinal zero will go directly to the head of the list. Stepping along sequential indexes then will return the next element of the list, remembering the new position at each step, thus allowing sequential access with little overhead as is expected for lists. If a random location is specified, then the list implementation must sequentially search for that ordinal from either the last location or an end of the list, incurring an overhead.

All collection classes implement a base set of functions, though they may be meaningless or degenerative in some collection types eg Insert()# for PSortedList# will degenerate to be the same as Append()#.

Definition at line 587 of file contain.h.


Comparison functions

virtual Comparison Compare (const PObject &obj) const
virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
bool operator!= (const PObject &obj) const
bool operator< (const PObject &obj) const
bool operator<= (const PObject &obj) const
bool operator== (const PObject &obj) const
bool operator> (const PObject &obj) const
bool operator>= (const PObject &obj) const
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }

Run Time Type functions

virtual const char * GetClass (unsigned=0) const
virtual BOOL InternalIsDescendant (const char *clsName) const
BOOL IsClass (const char *cls) const
static const char * Class ()

I/O functions

virtual void ReadFrom (istream &strm)
ostream & operator<< (ostream &strm, const PObject &obj)
istream & operator>> (istream &strm, PObject &obj)

Public Member Functions

Common functions for collections
PINLINE void AllowDeleteObjects (BOOL yes=TRUE)
virtual PINDEX Append (PObject *obj)=0
void DisallowDeleteObjects ()
virtual PObjectGetAt (PINDEX index) const =0
virtual PINDEX GetObjectsIndex (const PObject *obj) const =0
virtual PINDEX GetValuesIndex (const PObject &obj) const =0
virtual PINDEX Insert (const PObject &before, PObject *obj)=0
virtual PINDEX InsertAt (PINDEX index, PObject *obj)=0
virtual BOOL Remove (const PObject *obj)=0
virtual void RemoveAll ()
virtual PObjectRemoveAt (PINDEX index)=0
virtual BOOL SetAt (PINDEX index, PObject *val)=0
Miscellaneous functions
virtual PObjectClone () const
virtual PINDEX HashFunction () const
Common functions for containers
virtual PINDEX GetSize () const
virtual BOOL IsEmpty () const
BOOL IsUnique () const
virtual BOOL MakeUnique ()
BOOL SetMinSize (PINDEX minSize)
virtual BOOL SetSize (PINDEX newSize)=0
Construction
 PCollection (PINDEX initialSize=0)
Overrides from class PObject
virtual void PrintOn (ostream &strm) const

Protected Member Functions

virtual void AssignContents (const PContainer &c)
void CloneContents (const PContainer *src)
void CopyContents (const PContainer &c)
virtual void DestroyContents ()=0
void Destruct ()
PINLINE PCollection (int dummy, const PCollection *coll)

Protected Attributes

class PContainer::Reference * reference

Private Member Functions

 PCLASSINFO (PCollection, PContainer)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index