CVR-Lib last update 20 Sep 2009

cvr::smallObjectList< T > Class Template Reference

List of objects of small size. More...

#include <cvrSmallObjectList.h>

Inheritance diagram for cvr::smallObjectList< T >:

Inheritance graph
[legend]

List of all members.

Classes

class  const_iterator
 Const_iterator class (allows read-only operations). More...
class  iterator
 Iterator class (allows read and write operations) The use of the iterator classes is similar to the iterators of the STL (Standard Template Library). More...

Public Types

typedef unsigned int size_type
typedef T & reference
typedef const T & const_reference
typedef T * pointer
typedef const T * const_pointer
typedef T value_type

Public Member Functions

 smallObjectList ()
 smallObjectList (const smallObjectList &l)
 ~smallObjectList ()
size_type size () const
bool empty () const
void clear ()
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
iterator erase (iterator pos)
iterator erase (iterator first, iterator last)
iterator insert (iterator pos, const_iterator first, const_iterator last)
iterator insert (iterator pos, size_type n, const T &x)
iterator insert (iterator pos, const T &x)
void remove (const T &x)
void push_front (const T &x)
void push_back (const T &x)
void pop_front ()
void pop_back ()
reference front ()
const_reference front () const
reference back ()
const_reference back () const
void sort ()
template<class Compare >
void sort (Compare comp)
void swap (smallObjectList< T > &l)
void splice (iterator position, smallObjectList< T > &other)
void splice (iterator position, smallObjectList< T > &other, iterator it)
void splice (iterator position, smallObjectList< T > &other, iterator begin, iterator end)
smallObjectList< T > & operator= (const smallObjectList< T > &l)


Detailed Description

template<typename T>
class cvr::smallObjectList< T >

List of objects of small size.

The cvrsmallObjectList is an efficient implementation of a (double) linked list for small data types.

Each instance maintains its own heap, which may be expensive in memory consumption, but they are intended as very fast data structures with respect to memory reservation issues. It should serve, in many cases, as a drop-in replacement for std::list.

See also:
cvr::list

Member Typedef Documentation

template<typename T>
typedef const T* cvr::smallObjectList< T >::const_pointer

Const_pointer type (allows read-only operations) The use of the pointer classes is similar to the references of the STL (Standard Template Library).

template<typename T>
typedef const T& cvr::smallObjectList< T >::const_reference

Const_reference type (allows read-only operations) The use of the reference classes is similar to the references of the STL (Standard Template Library).

template<typename T>
typedef T* cvr::smallObjectList< T >::pointer

Pointer type (allows read and write operations) The use of the pointer classes is similar to the references of the STL (Standard Template Library).

template<typename T>
typedef T& cvr::smallObjectList< T >::reference

Reference type (allows read and write operations) The use of the reference classes is similar to the references of the STL (Standard Template Library).

template<typename T>
typedef unsigned int cvr::smallObjectList< T >::size_type

The type used to store the size of this list.

template<typename T>
typedef T cvr::smallObjectList< T >::value_type

The type of the values stored in the list.


Constructor & Destructor Documentation

template<typename T>
cvr::smallObjectList< T >::smallObjectList (  ) 

Default constructor.

Creates an empty smallObjectList.

template<typename T>
cvr::smallObjectList< T >::smallObjectList ( const smallObjectList< T > &  l  ) 

Copy constructor.

Creates a smallObjectList with the same contents as the given list.

template<typename T>
cvr::smallObjectList< T >::~smallObjectList (  ) 

Destructor.


Member Function Documentation

template<typename T>
const_reference cvr::smallObjectList< T >::back (  )  const

Returns a const_reference to the last element of the list.

template<typename T>
reference cvr::smallObjectList< T >::back (  ) 

Returns a reference to the last element of the list.

template<typename T>
const_iterator cvr::smallObjectList< T >::begin (  )  const

Returns a const_iterator pointing to the first element of the list.

The use of the interators is similar to the iterators of the Standard Template Library (STL).

template<typename T>
iterator cvr::smallObjectList< T >::begin (  ) 

Returns an iterator pointing to the first element of the list.

The use of the interators is similar to the iterators of the Standard Template Library (STL).

template<typename T>
void cvr::smallObjectList< T >::clear (  ) 

Empties the list.

template<typename T>
bool cvr::smallObjectList< T >::empty (  )  const

Returns true if the list has no elements, false otherwise.

template<typename T>
const_iterator cvr::smallObjectList< T >::end (  )  const

Returns a const_iterator pointing after the last element of the list.

The use of the interators is similar to the iterators of the Standard Template Library (STL).

template<typename T>
iterator cvr::smallObjectList< T >::end (  ) 

Returns an iterator pointing after the last element of the list.

The use of the interators is similar to the iterators of the Standard Template Library (STL).

template<typename T>
iterator cvr::smallObjectList< T >::erase ( iterator  first,
iterator  last 
)

Erases the elements between first and last, and returns an iterator pointing to the next element after last.

template<typename T>
iterator cvr::smallObjectList< T >::erase ( iterator  pos  ) 

Erases the element at position pos, and returns an iterator pointing to the next element after pos.

template<typename T>
const_reference cvr::smallObjectList< T >::front (  )  const

Returns a const_reference to the first element of the list.

template<typename T>
reference cvr::smallObjectList< T >::front (  ) 

Returns a reference to the first element of the list.

template<typename T>
iterator cvr::smallObjectList< T >::insert ( iterator  pos,
const T &  x 
)

Inserts x before pos, and returns an iterator pointing after the inserted element.

template<typename T>
iterator cvr::smallObjectList< T >::insert ( iterator  pos,
size_type  n,
const T &  x 
)

Inserts n copies of x before pos, and returns an iterator pointing after the last inserted element.

template<typename T>
iterator cvr::smallObjectList< T >::insert ( iterator  pos,
const_iterator  first,
const_iterator  last 
)

Inserts the range [first, last) before pos, and returns an iterator pointing after the last inserted element.

template<typename T>
smallObjectList<T>& cvr::smallObjectList< T >::operator= ( const smallObjectList< T > &  l  ) 

Assignment operator.

Clears this list, and copies the contents of the given list.

template<typename T>
void cvr::smallObjectList< T >::pop_back (  ) 

Removes the last element from the list.

template<typename T>
void cvr::smallObjectList< T >::pop_front (  ) 

Removes the first element from the list.

template<typename T>
void cvr::smallObjectList< T >::push_back ( const T &  x  ) 

Inserts x at the end of the list.

template<typename T>
void cvr::smallObjectList< T >::push_front ( const T &  x  ) 

Inserts x at the beginning of the list.

template<typename T>
void cvr::smallObjectList< T >::remove ( const T &  x  ) 

Removes all ocurrences of x found in the list.

If the value x is not in the list, the list remains unchanged.

Parameters:
x value to be removed from the list

template<typename T>
size_type cvr::smallObjectList< T >::size (  )  const

Returns the number of elements in the list.

template<typename T>
template<class Compare >
void cvr::smallObjectList< T >::sort ( Compare  comp  )  [inline]

Sorts this list according to the comparison function comp which must return a bool and take two arguments of type T.

template<typename T>
void cvr::smallObjectList< T >::sort (  ) 

Sorts this list according to the < operator.

template<typename T>
void cvr::smallObjectList< T >::splice ( iterator  position,
smallObjectList< T > &  other,
iterator  begin,
iterator  end 
)

Removes the elements in the interval [begin, end] from list other and inserts them before position in this list.

This is NOT a constant time operation. The computational cost is equivalent to use several insert and erase calls sequentially. The method is just provided for interface compatibility with the std::list.

template<typename T>
void cvr::smallObjectList< T >::splice ( iterator  position,
smallObjectList< T > &  other,
iterator  it 
)

Removes the element at it from list other and inserts it in this list before position.

This is NOT a constant time operation. The computational cost is equivalent to use insert and erase. The method is just provided for interface compatibility with the std::list.

template<typename T>
void cvr::smallObjectList< T >::splice ( iterator  position,
smallObjectList< T > &  other 
)

Inserts all elements from the given list other before the given position, and removes them from the given list.

This is a constant time operation.

template<typename T>
void cvr::smallObjectList< T >::swap ( smallObjectList< T > &  l  ) 

Swaps the contents of this list with the given list.


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

Generated on Sun Sep 20 22:09:09 2009 for CVR-Lib by Doxygen 1.5.8