Public Types | Public Member Functions | Private Member Functions | Private Attributes
karto::List< T > Class Template Reference

#include <List.h>

List of all members.

Public Types

typedef ConstListIterator< TConstIterator
typedef ListIterator< TIterator

Public Member Functions

virtual void Add (const T &rValue)
virtual void Add (const List &rValue)
virtual const TBack () const
kt_int32s BinarySearch (const T &rValue, kt_int32s(*f)(const T &a, const T &b))
virtual void Clear ()
virtual kt_bool Contains (const T &rValue) const
void EnsureCapacity (kt_size_t newCapacity)
TFind (const T &rValue)
virtual const TFront () const
virtual TGet (kt_size_t index)
virtual const TGet (kt_size_t index) const
virtual ConstListIterator< TGetConstIterator () const
virtual ListIterator< TGetIterator ()
virtual kt_bool IsEmpty () const
 List ()
 List (kt_size_t size)
 List (const List &rOther)
Listoperator= (const List &rOther)
kt_bool operator== (const List &rOther) const
Toperator[] (kt_size_t index)
const Toperator[] (kt_size_t index) const
virtual kt_bool Remove (const T &rValue)
virtual void RemoveAt (kt_size_t index)
virtual void Resize (kt_size_t newSize)
void Set (kt_size_t index, const T &rValue)
virtual kt_size_t Size () const
virtual ~List ()

Private Member Functions

void Reset ()

Private Attributes

kt_size_t m_Capacity
Tm_pElements
kt_size_t m_Size

Detailed Description

template<class T>
class karto::List< T >

List class with boundary check. Any class that is used with List MUST implement operator==. Implementation notes: Do NOT use memcpy/memset (does not work with smart pointers)

Definition at line 49 of file List.h.


Member Typedef Documentation

template<class T>
typedef ConstListIterator<T> karto::List< T >::ConstIterator

Type definition for const iterator

Definition at line 55 of file List.h.

template<class T>
typedef ListIterator<T> karto::List< T >::Iterator

Type definition for iterator

Definition at line 60 of file List.h.


Constructor & Destructor Documentation

template<class T>
karto::List< T >::List ( ) [inline]

Constructs an empty list

Definition at line 65 of file List.h.

template<class T>
karto::List< T >::List ( kt_size_t  size) [inline]

Construct a list of given size

Parameters:
sizedesired size

Definition at line 75 of file List.h.

template<class T>
karto::List< T >::List ( const List< T > &  rOther) [inline]

Copy constructor

Definition at line 85 of file List.h.

template<class T>
virtual karto::List< T >::~List ( ) [inline, virtual]

Destructor

Definition at line 100 of file List.h.


Member Function Documentation

template<class T>
virtual void karto::List< T >::Add ( const T rValue) [inline, virtual]

Adds the given value to the end of the list. Runs in amortized O(1) time.

Parameters:
rValuevalue to be added

Definition at line 111 of file List.h.

template<class T>
virtual void karto::List< T >::Add ( const List< T > &  rValue) [inline, virtual]

Appends the given list to this list

Parameters:
rValuelist to be added

Definition at line 126 of file List.h.

template<class T>
virtual const T& karto::List< T >::Back ( ) const [inline, virtual]

Last item in the list (list must have at least one item)

Returns:
last item in the list
Exceptions:
Exceptionif list is empty

Definition at line 319 of file List.h.

template<class T>
kt_int32s karto::List< T >::BinarySearch ( const T rValue,
kt_int32s(*)(const T &a, const T &b)  f 
) [inline]

Searches for value in list using given comparator f. Elements must be in sorted order for this function to work properly.

Parameters:
rValuevalue to search for
fcomparator takes two elements; returns 0 if the elements are equal, a value less than 0 if the first value is less than the second value, and a value greater than 0 if the first value is greater than the second value
Returns:
index into list that is element or -1 if not found

Definition at line 380 of file List.h.

template<class T>
virtual void karto::List< T >::Clear ( ) [inline, virtual]

Clears this list

Definition at line 231 of file List.h.

template<class T>
virtual kt_bool karto::List< T >::Contains ( const T rValue) const [inline, virtual]

Check if this list contains the given value

Parameters:
rValuevalue to search for
Returns:
true if this list contains the given value

Definition at line 197 of file List.h.

template<class T>
void karto::List< T >::EnsureCapacity ( kt_size_t  newCapacity) [inline]

Reserves capacity (for efficiency purposes). Don't use [] but Add() instead!

Parameters:
newCapacitynew capacity

Definition at line 361 of file List.h.

template<class T>
T* karto::List< T >::Find ( const T rValue) [inline]

Finds the given value in the list

Parameters:
rValuevalue to search for
Returns:
pointer to item in list or NULL if not found

Definition at line 270 of file List.h.

template<class T>
virtual const T& karto::List< T >::Front ( ) const [inline, virtual]

First item in the list (list must have at least one item)

Returns:
first item in the list
Exceptions:
Exceptionif list is empty

Definition at line 303 of file List.h.

template<class T>
virtual T& karto::List< T >::Get ( kt_size_t  index) [inline, virtual]

Gets the item at the given index

Parameters:
indexindex
Returns:
item at given index

Definition at line 250 of file List.h.

template<class T>
virtual const T& karto::List< T >::Get ( kt_size_t  index) const [inline, virtual]

Gets the item at the given index (const version)

Parameters:
indexindex
Returns:
item at given index

Definition at line 260 of file List.h.

template<class T>
virtual ConstListIterator<T> karto::List< T >::GetConstIterator ( ) const [inline, virtual]

Gets a const list iterator of this list

Returns:
const list iterator of this list

Definition at line 494 of file List.h.

template<class T>
virtual ListIterator<T> karto::List< T >::GetIterator ( ) [inline, virtual]

Gets a list iterator of this list

Returns:
list iterator of this list

Definition at line 503 of file List.h.

template<class T>
virtual kt_bool karto::List< T >::IsEmpty ( ) const [inline, virtual]

Checks if this list is empty

Returns:
true if this list is empty, false otherwise

Definition at line 223 of file List.h.

template<class T>
List& karto::List< T >::operator= ( const List< T > &  rOther) [inline]

Assignment operator

Definition at line 444 of file List.h.

template<class T>
kt_bool karto::List< T >::operator== ( const List< T > &  rOther) const [inline]

Equality operator

Definition at line 462 of file List.h.

template<class T>
T& karto::List< T >::operator[] ( kt_size_t  index) [inline]

Gets the item at the given index

Parameters:
indexindex
Returns:
item at given index

Definition at line 414 of file List.h.

template<class T>
const T& karto::List< T >::operator[] ( kt_size_t  index) const [inline]

Gets the item at the given index (const version)

Parameters:
indexindex
Returns:
item at given index

Definition at line 430 of file List.h.

template<class T>
virtual kt_bool karto::List< T >::Remove ( const T rValue) [inline, virtual]

Removes the first instance of the given value (does nothing if the value is not found). This method runs in O(n) time.

Parameters:
rValuevalue to be removed
Returns:
true if item was removed, false otherwise

Definition at line 148 of file List.h.

template<class T>
virtual void karto::List< T >::RemoveAt ( kt_size_t  index) [inline, virtual]

Removes an element at index

Parameters:
indexindex

Definition at line 166 of file List.h.

template<class T>
void karto::List< T >::Reset ( ) [inline, private]

Definition at line 481 of file List.h.

template<class T>
virtual void karto::List< T >::Resize ( kt_size_t  newSize) [inline, virtual]

Resizes the list. Sets the Size() to be newSize so don't use Add() but [] instead!

Parameters:
newSizenew size

Definition at line 334 of file List.h.

template<class T>
void karto::List< T >::Set ( kt_size_t  index,
const T rValue 
) [inline]

Sets the item at the given index to the given value

Parameters:
indexindex
rValuenew value to place at given index

Definition at line 288 of file List.h.

template<class T>
virtual kt_size_t karto::List< T >::Size ( ) const [inline, virtual]

Gets the size of this list

Returns:
size of this list

Definition at line 214 of file List.h.


Member Data Documentation

template<class T>
kt_size_t karto::List< T >::m_Capacity [private]

Definition at line 511 of file List.h.

template<class T>
T* karto::List< T >::m_pElements [private]

Definition at line 509 of file List.h.

template<class T>
kt_size_t karto::List< T >::m_Size [private]

Definition at line 510 of file List.h.


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


nav2d_karto
Author(s): Sebastian Kasperski
autogenerated on Sun Apr 2 2017 03:53:09