Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize > Class Template Reference

#include <Container.hpp>

List of all members.


Detailed Description

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
class Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >

The IndexList holds pointers to object passed in.

Pros : Almost as fast as array's access time once constructed. Element order is always preserved. Cons : Construction / Adding and Remove operations are slow (but faster than array) because of some copying is done for each pointer in the list

It's best if used like

            // Create an index list
            IndexList<MyObj> myList;
            myList.Append(new MyObj(something));
            // This will delete the inserted object by using the selected policy (delete in this example)
            myList.Remove(0); 
            myList.insertBefore(2, new MyObj(foo)); // Index can be out of range
            myList.insertBefore(0, new MyObj(bar));
            // Get a reference on the list element
            const MyObj & ref = myList[1];
            // Search for an element based on its address
            assert(1 == myList.indexOf(&ref));    
            // Search for an element based on its value (much slower)
            assert(1 == myList.indexOfMatching(ref));

Policy must follow the MemoryPolicy interface

See also:
MemoryPolicy


Public Member Functions

void Append (const TPtr &ref) throw ()
 Append an element to the end of the array.
void Clear ()
 Clear the array, and destruct any remaining objects.
TPtr & getElementAtUncheckedPosition (uint32 index)
 Fast access operator, but doesn't check the index given in.
size_t getSize () const
 Access size member.
 IndexList (const IndexList &other)
 Copy constructor.
 IndexList ()
 Default Constructor.
uint32 indexOf (const TPtr &objectToSearch)
 Search operator.
uint32 indexOfMatching (const TElem &objectToSearch)
 Search operator.
void insertBefore (uint32 index, const TPtr &ref) throw ()
 Insert an element just before the given index.
uint32 lastIndexOf (const TPtr &objectToSearch)
 Reverse search operator.
const IndexListoperator= (const IndexList &other)
 Classic copy operator.
bool operator== (const IndexList &other)
 Compare operator.
TElem & operator[] (uint32 index)
 Access operator.
void Remove (uint32 index) throw ()
 Remove an object from the array.
 ~IndexList ()
 Destructor.


Constructor & Destructor Documentation

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::IndexList (  )  [inline]

Default Constructor.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::IndexList ( const IndexList< TElem, Policy, ExactSize > &  other  )  [inline]

Copy constructor.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::~IndexList (  )  [inline]

Destructor.


Member Function Documentation

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
void Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::Append ( const TPtr &  ref  )  throw () [inline]

Append an element to the end of the array.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
void Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::Clear (  )  [inline]

Clear the array, and destruct any remaining objects.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
TPtr& Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::getElementAtUncheckedPosition ( uint32  index  )  [inline]

Fast access operator, but doesn't check the index given in.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
size_t Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::getSize (  )  const [inline]

Access size member.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
uint32 Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::indexOf ( const TPtr &  objectToSearch  )  [inline]

Search operator.

Parameters:
objectToSearch The object to look for in the array based on the given address
Returns:
the element index of the given element or getSize() if not found.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
uint32 Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::indexOfMatching ( const TElem &  objectToSearch  )  [inline]

Search operator.

Parameters:
objectToSearch The object to look for in the array
Returns:
the element index of the given element or getSize() if not found.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
void Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::insertBefore ( uint32  index,
const TPtr &  ref 
) throw () [inline]

Insert an element just before the given index.

Parameters:
index Zero based index of the element once inserted
Warning:
If index is out of range, the element is appended instead.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
uint32 Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::lastIndexOf ( const TPtr &  objectToSearch  )  [inline]

Reverse search operator.

Parameters:
objectToSearch The object to look for in the array
Returns:
the element index of the given element or getSize() if not found.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
const IndexList& Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::operator= ( const IndexList< TElem, Policy, ExactSize > &  other  )  [inline]

Classic copy operator.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
bool Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::operator== ( const IndexList< TElem, Policy, ExactSize > &  other  )  [inline]

Compare operator.

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
TElem& Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::operator[] ( uint32  index  )  [inline]

Access operator.

Parameters:
index The position in the array
Returns:
the index-th element if index is in bound, or Policy::DefaultElement() else

template<typename TElem, class Policy = MemoryListPolicy<TElem>, bool ExactSize = false>
void Container::PrivateGenericImplementation::IndexList< TElem, Policy, ExactSize >::Remove ( uint32  index  )  throw () [inline]

Remove an object from the array.

Parameters:
index Index of the object to remove


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

(C) An X-Ryl669 project 2007

This document describes Unlimited Zooming Interface source code. UZI stands for Unlimited Zooming Interface, and source code license is