This class is a collection of objects which are descendents of the PObject class.
![]() | Construction |
![]() | Overrides from class PObject |
![]() | Overrides from class PContainer |
![]() | Overrides from class PCollection |
Common functions for collections
Common functions for containers
Run Time Type functions
Comparison functions
I/O functions
Miscellaneous functions
This class is a collection of objects which are descendents of the PObject class. It is implemeted as a Red-Black binary tree to maintain the objects in rank order. Note that this requires that the PObject::Compare() function be fully implemented oin objects contained in the collection.The implementation of a sorted list allows fast inserting and deleting as well as random access of objects in the collection. As the objects are being kept sorted, "fast" is a relative term. All operations take o(lg n) unless a particular object is repeatedly accessed.
The class remembers the last accessed element. This state information is used to optimise access by the "virtual array" model of collections. If repeated access via ordinal index is made there is little overhead. All other access incurs a minimum overhead, but not insignificant.
The PAbstractSortedList class would very rarely be descended from directly by the user. The PDECLARE_LIST and PLIST macros would normally be used to create descendent classes. They will instantiate the template based on PSortedList or directly declare and define the class (using inline functions) if templates are not being used.
The PSortedList class or PDECLARE_SORTED_LIST macro will define the correctly typed operators for subscript access (operator[]).
Note that by default, objects placed into the list will be deleted when removed or when all references to the list are destroyed.
This is also returned if all objects are equal and the instances list length is less than the obj parameters list length.
This is also returned if all objects are equal and the instances list length is greater than the obj parameters list length. \end{descriptions}
The object is always placed in the correct ordinal position in the list.
It is not placed at the specified position. The before
parameter is ignored.
The object is always placed in the correct ordinal position in the list.
It is not placed at the specified position. The
parameter is ignored.
Note that the comparison for searching for the object in collection is
made by pointer, not by value. Thus the parameter must point to the
same instance of the object that is in the collection.
Note if the index is beyond the size of the collection then the
function will assert.
The objects are removed from the last, at index
(GetSize()-1) toward the first at index zero.
Note, the object placed at
ordinal position. It is actually placed at the correct position for its
rank.
Note that that will require value comparisons to be made to find the
equivalent entry and then a final check is made with the pointers to
see if they are the same instance.
virtual PINDEX Insert( const PObject & before, PObject * obj )
virtual PINDEX InsertAt( PINDEX index, PObject * obj )
virtual BOOL Remove( const PObject * obj )
virtual PObject* RemoveAt( PINDEX index )
virtual void RemoveAll()
virtual BOOL SetAt( PINDEX index, PObject * val )
virtual PObject* GetAt( PINDEX index ) const
virtual PINDEX GetObjectsIndex( const PObject * obj ) const
virtual PINDEX GetValuesIndex( const PObject & obj ) const
Alphabetic index HTML hierarchy of classes or Java