Template container base class (abstract). More...
#include <tcontainer.h>
Public Member Functions | |
TContainer () | |
TContainer (const TContainer< T > &) | |
virtual | ~TContainer () |
bool | operator== (const TContainer< T > &) const |
bool | operator!= (const TContainer< T > &) const |
virtual TContainer< T > * | newInstance () const =0 |
Create a copy of this container. | |
T & | operator[] (int32) const |
"[]" indexing operator returns the item at the specified index. | |
virtual int32 | total () const |
Return number of items. | |
virtual bool | isEmpty () const |
Is container empty? | |
virtual int32 | size () const |
Returns the container size. | |
virtual bool | add (const T &item)=0 |
Add item to container. | |
virtual bool | remove (const T &item)=0 |
Remove equal item. | |
virtual bool | remove (const TIterator< T > &)=0 |
Remove item at current iterator position. | |
virtual bool | removeAt (int32 index)=0 |
Remove item at given index. | |
virtual void | removeAll ()=0 |
Remove all items from list. | |
virtual T & | at (int32 index) const |
Get item at index. | |
virtual T & | lookup (const T &item) const |
Searches for the item equal to the specified item in the list and returns the first occurrence. | |
virtual bool | contains (const T &item) const |
See if container has equal item. | |
virtual int32 | occurrences (const T &item) const |
Count occurrences of equal items. | |
virtual TIterator< T > * | newIterator () const =0 |
Create container iterator instance. | |
TContainer< T > * | lookupAll (const T &item) const |
Allocate and returns a container with all items in this container equal to the specified item. | |
bool | addAllFrom (const TContainer< T > &container) |
Adds all the items from the specified container to this container. | |
bool | addNewFrom (const TContainer< T > &container) |
Adds the items from the specified container to this container that are not in this container already. | |
T & | error () const |
Access error object. | |
Protected Member Functions | |
void | copy (const TContainer< T > &container) |
Internal copy method. Copies the contents of the specified container into this container. | |
Protected Attributes | |
T | errorObject |
Object used as return value when methods returning a T& fail. | |
int32 | _size |
Container size. |
Template container base class (abstract).
This class defines the basic interface for any container implementation in this module.
Please note that:
TArray<int> myArray; myArray.error () = -1;
TContainer | ( | ) | [inline] |
TContainer | ( | const TContainer< T > & | ) | [inline] |
~TContainer | ( | ) | [inline, virtual] |
bool operator== | ( | const TContainer< T > & | other | ) | const [inline] |
bool operator!= | ( | const TContainer< T > & | other | ) | const [inline] |
virtual TContainer<T>* newInstance | ( | ) | const [pure virtual] |
Create a copy of this container.
Implemented in TArray< T >, TOrderedArray< T >, TSortableArray< T >, TBinaryTree< T >, TBTree< T >, TDLinkedList< T >, THashTable< T >, TLinkedList< T >, TArray< Rect >, TArray< TAssociation< K, O > >, TArray< Block >, TArray< void * >, TArray< FObjectBlock * >, TBTree< TAssociation< K, O > >, TDLinkedList< TAssociation< TKey, TObject > >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
T & operator[] | ( | int32 | idx | ) | const [inline] |
"[]" indexing operator returns the item at the specified index.
int32 total | ( | ) | const [inline, virtual] |
Return number of items.
Reimplemented in TArrayBase< T >, THashTable< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
bool isEmpty | ( | ) | const [inline, virtual] |
Is container empty?
Reimplemented in TArrayBase< T >, THashTable< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
int32 size | ( | ) | const [inline, virtual] |
Returns the container size.
The size of a container can be larger than the number of items it contains. For example the TArray implementation returns the number of items that fit into the allocated memory and not the number of actually inserted items
virtual bool add | ( | const T & | item | ) | [pure virtual] |
Add item to container.
Implemented in TArrayBase< T >, TBag< T >, TBinaryTree< T >, TBTree< T >, TBTreeSet< T >, TDLinkedList< T >, THashSet< T >, THashTable< T >, TLinkedList< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, TBTree< TAssociation< K, O > >, TDLinkedList< TAssociation< TKey, TObject > >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
virtual bool remove | ( | const T & | item | ) | [pure virtual] |
Remove equal item.
Implemented in TArrayBase< T >, TBag< T >, TBinaryTree< T >, TBTree< T >, TDLinkedList< T >, THashTable< T >, TLinkedList< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, TBTree< TAssociation< K, O > >, TDLinkedList< TAssociation< TKey, TObject > >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
virtual bool remove | ( | const TIterator< T > & | ) | [pure virtual] |
Remove item at current iterator position.
Implemented in TArrayBase< T >, TBinaryTree< T >, TBTree< T >, TDLinkedList< T >, THashTable< T >, TLinkedList< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, TBTree< TAssociation< K, O > >, TDLinkedList< TAssociation< TKey, TObject > >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
virtual bool removeAt | ( | int32 | index | ) | [pure virtual] |
Remove item at given index.
Implemented in TArrayBase< T >, TBinaryTree< T >, TBTree< T >, TDLinkedList< T >, THashTable< T >, TLinkedList< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, TBTree< TAssociation< K, O > >, TDLinkedList< TAssociation< TKey, TObject > >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
virtual void removeAll | ( | ) | [pure virtual] |
Remove all items from list.
Implemented in TArrayBase< T >, TBag< T >, TBinaryTree< T >, TBTree< T >, TDLinkedList< T >, THashTable< T >, TLinkedList< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, TBTree< TAssociation< K, O > >, TDLinkedList< TAssociation< TKey, TObject > >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
T & at | ( | int32 | index | ) | const [inline, virtual] |
Get item at index.
Reimplemented in TArrayBase< T >, TDLinkedList< T >, TLinkedList< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, and TDLinkedList< TAssociation< TKey, TObject > >.
T & lookup | ( | const T & | item | ) | const [inline, virtual] |
Searches for the item equal to the specified item in the list and returns the first occurrence.
Reimplemented in TArrayBase< T >, TBinaryTree< T >, TBTree< T >, TDLinkedList< T >, THashTable< T >, TLinkedList< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, TBTree< TAssociation< K, O > >, TDLinkedList< TAssociation< TKey, TObject > >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
bool contains | ( | const T & | item | ) | const [inline, virtual] |
See if container has equal item.
Reimplemented in TArrayBase< T >, TBinaryTree< T >, TBTree< T >, TDLinkedList< T >, THashTable< T >, TLinkedList< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, TBTree< TAssociation< K, O > >, TDLinkedList< TAssociation< TKey, TObject > >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
int32 occurrences | ( | const T & | item | ) | const [inline, virtual] |
Count occurrences of equal items.
Reimplemented in TArrayBase< T >, TBinaryTree< T >, TBTree< T >, TDLinkedList< T >, THashTable< T >, TLinkedList< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, TBTree< TAssociation< K, O > >, TDLinkedList< TAssociation< TKey, TObject > >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
virtual TIterator<T>* newIterator | ( | ) | const [pure virtual] |
Create container iterator instance.
Implemented in TArrayBase< T >, TBinaryTree< T >, TBTree< T >, TDLinkedList< T >, THashTable< T >, TLinkedList< T >, TArrayBase< Rect >, TArrayBase< TAssociation< K, O > >, TArrayBase< Block >, TArrayBase< void * >, TArrayBase< FObjectBlock * >, TBTree< TAssociation< K, O > >, TDLinkedList< TAssociation< TKey, TObject > >, THashTable< SorterByCID >, THashTable< TAssociation< TKey, TObject > >, and THashTable< SorterByName >.
TContainer< T > * lookupAll | ( | const T & | item | ) | const [inline] |
Allocate and returns a container with all items in this container equal to the specified item.
bool addAllFrom | ( | const TContainer< T > & | container | ) | [inline] |
Adds all the items from the specified container to this container.
bool addNewFrom | ( | const TContainer< T > & | container | ) | [inline] |
Adds the items from the specified container to this container that are not in this container already.
T& error | ( | ) | const [inline] |
Access error object.
void copy | ( | const TContainer< T > & | container | ) | [inline, protected] |
Internal copy method. Copies the contents of the specified container into this container.
T errorObject [protected] |
Object used as return value when methods returning a T& fail.
int32 _size [protected] |
Container size.