SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
sutil::CMappedMultiLevelList< Idx, T > Class Template Reference

#include <CMappedMultiLevelList.hpp>

Inheritance diagram for sutil::CMappedMultiLevelList< Idx, T >:
Inheritance graph
[legend]
Collaboration diagram for sutil::CMappedMultiLevelList< Idx, T >:
Collaboration graph
[legend]

Public Types

typedef size_t size_type
 
typedef ptrdiff_t difference_type
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef T value_type
 

Public Member Functions

 CMappedMultiLevelList ()
 
virtual ~CMappedMultiLevelList ()
 
virtual T * create (const Idx &arg_idx, const T &arg_node2add, const std::size_t arg_priority)
 
virtual T * create (const Idx &arg_idx, const std::size_t arg_priority)
 
virtual T * insert (const Idx &arg_idx, T *arg_node2add, const std::size_t arg_priority)
 
virtual CMappedMultiLevelList
< Idx, T > & 
operator= (const CMappedMultiLevelList< Idx, T > &arg_rhs)
 
virtual bool erase (T *arg_t)
 
virtual bool erase (const Idx &arg_idx)
 
virtual bool clear ()
 
std::vector< T * > * getSinglePriorityLevel (std::size_t arg_pri)
 
std::size_t getNumPriorityLevels () const
 
int getPriorityLevel (T *arg_t)
 
int getPriorityLevel (const Idx &arg_idx)
 
bool operator== (const CMappedList< Idx, T > &rhs)
 
bool operator!= (const CMappedList< Idx, T > &rhs)
 
void swap (CMappedList< Idx, T > &arg_swap_obj)
 
virtual T * create (const Idx &arg_idx, const bool insert_at_start=true)
 
virtual T * create (const Idx &arg_idx, const T &arg_t, const bool insert_at_start=true)
 
virtual T * insert (const Idx &arg_idx, T *arg_t, const bool insert_at_start=true)
 
virtual T * at (const std::size_t arg_idx)
 
virtual T * at (const Idx &arg_idx)
 
virtual const Idx * getIndexAt (const std::size_t arg_idx) const
 
virtual int getIndexNumericAt (const Idx &arg_idx) const
 
virtual int getIndexNumericAt (const T *const arg_node) const
 
virtual const T * at_const (const std::size_t arg_idx) const
 
virtual const T * at_const (const Idx &arg_idx) const
 
virtual std::size_t size () const
 
virtual bool empty () const
 
virtual T * operator[] (const std::size_t arg_idx)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
virtual bool sort (const std::vector< Idx > &arg_order)
 
virtual bool sort_get_order (std::vector< Idx > &ret_order) const
 
virtual bool isSorted () const
 

Public Attributes

std::vector< std::vector< T * > > mlvec_
 

Protected Member Functions

virtual bool deepCopy (const CMappedMultiLevelList< Idx, T > *arg_br)
 
virtual bool deepCopy (const CMappedList< Idx, T > *const arg_pmap)
 

Protected Attributes

std::map< const T *, std::size_t > map_nodeptr2pri_
 
std::size_t pri_levels_
 
SMLNode< Idx, T > * front_
 
SMLNode< Idx, T > * back_
 
SMLNode< Idx, T > null_
 
std::map< Idx, SMLNode< Idx, T > * > map_
 
std::size_t size_
 
std::vector< Idx > sorting_order_
 
bool flag_is_sorted_
 

Detailed Description

template<typename Idx, typename T>
class sutil::CMappedMultiLevelList< Idx, T >

This template class contains a multi level linked list.

It is an extension of a PileMap, which itself is a collection of pointers (memory managed) stored in a linked list.

Member Typedef Documentation

template<typename Idx, typename T>
typedef size_t sutil::CMappedList< Idx, T >::size_type
inherited

STL container specific code: (a) A set of typedefs (b) An iterator definition (c) Standard methods



The standard stl typedefs:


Constructor & Destructor Documentation

template<typename Idx , typename T >
sutil::CMappedMultiLevelList< Idx, T >::CMappedMultiLevelList ( )

Constructor : Empties the data structure

Constructor. Sets default values.

template<typename Idx , typename T >
sutil::CMappedMultiLevelList< Idx, T >::~CMappedMultiLevelList ( )
virtual

Destructor : Deallocates all the nodes if someone already hasn't done so.

Does nothing itself. Calls CMappedList::~CMappedList() which destroys the (dynamically allocated) nodes in the node linked list.

Member Function Documentation

template<typename Idx , typename T >
T * sutil::CMappedList< Idx, T >::at ( const std::size_t  arg_idx)
virtualinherited

Returns the element at the given numerical index in the linked list (usually useful only for debugging)

NOTE : The index starts at 0

template<typename Idx, typename T >
T * sutil::CMappedList< Idx, T >::at ( const Idx &  arg_idx)
virtualinherited

Returns the element referenced by the index

NOTE : This uses the std::map (and is somewhat slow)

template<typename Idx , typename T >
const T * sutil::CMappedList< Idx, T >::at_const ( const std::size_t  arg_idx) const
virtualinherited

Returns the element at the given numerical index in the linked list (usually useful only for debugging)

NOTE : The index starts at 0

template<typename Idx, typename T >
const T * sutil::CMappedList< Idx, T >::at_const ( const Idx &  arg_idx) const
virtualinherited

Returns a const pointer to the element referenced by the index

NOTE : This uses the std::map (and is rather slow)

template<typename Idx, typename T>
iterator sutil::CMappedList< Idx, T >::begin ( )
inlineinherited

The iterator functions


template<typename Idx , typename T >
bool sutil::CMappedMultiLevelList< Idx, T >::clear ( )
virtual

Clears all elements from the list

Reimplemented from sutil::CMappedList< Idx, T >.

template<typename Idx, typename T>
T * sutil::CMappedMultiLevelList< Idx, T >::create ( const Idx &  arg_idx,
const T &  arg_node2add,
const std::size_t  arg_priority 
)
virtual

Adds a node to the mapped list and inserts its vector into the appropriate slot in the vector-list

Adds a node at the given level and returns its address.

template<typename Idx, typename T>
T * sutil::CMappedMultiLevelList< Idx, T >::create ( const Idx &  arg_idx,
const std::size_t  arg_priority 
)
virtual

Adds a node to the mapped list and inserts its vector into the appropriate slot in the vector-list. Uses the copy-constructor.

template<typename Idx, typename T >
T * sutil::CMappedList< Idx, T >::create ( const Idx &  arg_idx,
const bool  insert_at_start = true 
)
virtualinherited

Example usage: first.assign (7,100); // 7 ints with value 100 second.assign (first.begin(),first.end()); // a copy of first ******************************* The mapped list specific methods


Creates an element, inserts an element into the list and returns the pointer

Reimplemented in sutil::CMappedTree< TIdx, TNode >, sutil::CMappedTree< std::string, scl::SRigidBodyDyn >, sutil::CMappedTree< std::string, scl::SRigidBody >, and sutil::CMappedTree< std::string, scl::SGraphicsChaiRigidBody >.

template<typename Idx, typename T>
T * sutil::CMappedList< Idx, T >::create ( const Idx &  arg_idx,
const T &  arg_t,
const bool  insert_at_start = true 
)
virtualinherited

Copies the given element, inserts the copied element into the list and returns the pointer to the copied element.

By default inserts element at the start/begin() position. If specified, flag is false, inserts at the end of the list.

If size is zero, insert at start/end doesn't matter.

Reimplemented in sutil::CMappedTree< TIdx, TNode >, sutil::CMappedTree< std::string, scl::SRigidBodyDyn >, sutil::CMappedTree< std::string, scl::SRigidBody >, and sutil::CMappedTree< std::string, scl::SGraphicsChaiRigidBody >.

template<typename Idx, typename T>
bool sutil::CMappedList< Idx, T >::deepCopy ( const CMappedList< Idx, T > *const  arg_pmap)
protectedvirtualinherited

Does a deep copy of the mappedlist to get a new one. This is VERY SLOW.

Set the current mappedlist to the new mappedlist

template<typename Idx, typename T>
bool sutil::CMappedMultiLevelList< Idx, T >::deepCopy ( const CMappedMultiLevelList< Idx, T > *  arg_br)
protectedvirtual

These functions exist in the parent class, but are not to be called by pointers to this class. The overloaded equivalents in this class are the replacements. For more information, read the documentation related to -Woverloaded-virtual

NOTE TODO : This needs to be protected here. T* CMappedList<Idx,T>::create(const Idx & arg_idx, const bool insert_at_start); Copy-Constructor : Does a deep copy of the mapped multi level list to get a new one. NOTE : This uses the passed mapped list's iterator construct.

Set the current mapped list to the new mapped list

template<typename Idx, typename T>
virtual bool sutil::CMappedList< Idx, T >::empty ( ) const
inlinevirtualinherited

Is the container empty

template<typename Idx , typename T>
bool sutil::CMappedMultiLevelList< Idx, T >::erase ( T *  arg_t)
virtual

Erases an element from the list. Referenced by the element's memory location

Reimplemented from sutil::CMappedList< Idx, T >.

template<typename Idx, typename T>
bool sutil::CMappedMultiLevelList< Idx, T >::erase ( const Idx &  arg_idx)
virtual

Erases an element from the list. Referenced by its index

Reimplemented from sutil::CMappedList< Idx, T >.

template<typename Idx , typename T >
const Idx * sutil::CMappedList< Idx, T >::getIndexAt ( const std::size_t  arg_idx) const
virtualinherited

Returns the typed index at the given numerical index in the linked list

NOTE : The index starts at 0

template<typename Idx, typename T >
int sutil::CMappedList< Idx, T >::getIndexNumericAt ( const Idx &  arg_idx) const
virtualinherited

Returns the numeric index at the given typed index in the linked list

NOTE : The index starts at 0. Returns -1 if node not found.

Returns the numeric index at the given typed index in the linked list

template<typename Idx, typename T>
int sutil::CMappedList< Idx, T >::getIndexNumericAt ( const T *const  arg_node) const
virtualinherited

Returns the numeric index at the given typed index in the linked list

NOTE : The index starts at 0. Returns -1 if node not found.

Returns the numeric index at the given typed index in the linked list

template<typename Idx , typename T>
int sutil::CMappedMultiLevelList< Idx, T >::getPriorityLevel ( T *  arg_t)

Returns the priority level of the element Note: This returns an int because -1 is the error condition

template<typename Idx, typename T>
int sutil::CMappedMultiLevelList< Idx, T >::getPriorityLevel ( const Idx &  arg_idx)

Returns the priority level of the element pointed to by the index Note: This returns an int because -1 is the error condition

template<typename Idx , typename T >
std::vector< T * > * sutil::CMappedMultiLevelList< Idx, T >::getSinglePriorityLevel ( std::size_t  arg_pri)

Returns the tasks at a level

template<typename Idx, typename T>
T * sutil::CMappedMultiLevelList< Idx, T >::insert ( const Idx &  arg_idx,
T *  arg_node2add,
const std::size_t  arg_priority 
)
virtual

Adds an existing object to the mapped list and inserts its vector into the appropriate slot in the vector-list

Adds a node at the given level and returns its address.

template<typename Idx, typename T>
T * sutil::CMappedList< Idx, T >::insert ( const Idx &  arg_idx,
T *  arg_t,
const bool  insert_at_start = true 
)
virtualinherited

Inserts the given object into the list and returns the pointer to the copied element. NOTE : The recommended method is to use create. Else the object memory deallocation might be ambiguous. Remember that the mapped list "always" clears its own data.

By default inserts element at the start/begin() position. If specified, flag is false, inserts at the end of the list.

If size is zero, insert at start/end doesn't matter.

Reimplemented in sutil::CMappedTree< TIdx, TNode >, sutil::CMappedTree< std::string, scl::SRigidBodyDyn >, sutil::CMappedTree< std::string, scl::SRigidBody >, and sutil::CMappedTree< std::string, scl::SGraphicsChaiRigidBody >.

template<typename Idx, typename T>
virtual bool sutil::CMappedList< Idx, T >::isSorted ( ) const
inlinevirtualinherited

Whether the list has been sorted or not

template<typename Idx, typename T>
bool sutil::CMappedList< Idx, T >::operator!= ( const CMappedList< Idx, T > &  rhs)
inherited

Comparison operator : Performs an element-by-element check (std container requirement). Beware; This can be quite slow.

template<typename Idx, typename T>
virtual CMappedMultiLevelList<Idx,T>& sutil::CMappedMultiLevelList< Idx, T >::operator= ( const CMappedMultiLevelList< Idx, T > &  arg_rhs)
inlinevirtual

Assignment operator : Performs a deep-copy (std container requirement). Beware; This can be quite slow.

template<typename Idx, typename T>
bool sutil::CMappedList< Idx, T >::operator== ( const CMappedList< Idx, T > &  rhs)
inherited

Comparison operator : Performs an element-by-element check (std container requirement). Beware; This can be quite slow.

template<typename Idx, typename T>
virtual T* sutil::CMappedList< Idx, T >::operator[] ( const std::size_t  arg_idx)
inlinevirtualinherited

Typical operator access

template<typename Idx, typename T>
virtual std::size_t sutil::CMappedList< Idx, T >::size ( ) const
inlinevirtualinherited

Returns the size of the mapped list

template<typename Idx, typename T >
bool sutil::CMappedList< Idx, T >::sort ( const std::vector< Idx > &  arg_order)
virtualinherited

Sorting related functions


Sorts the list so that iterator access matches the given vector's index. Ie. Given indices 0 to n in the vector, the begin() iterator will match 0, and the end() will appear after iterating over n.

Any create/erase/swap etc. function call will invalidate the sort ordering.

Sorting type : Insertion Sort.

template<typename Idx, typename T>
virtual bool sutil::CMappedList< Idx, T >::sort_get_order ( std::vector< Idx > &  ret_order) const
inlinevirtualinherited

Get the sorting order if there is one

template<typename Idx, typename T>
void sutil::CMappedList< Idx, T >::swap ( CMappedList< Idx, T > &  arg_swap_obj)
inherited

Swaps the elements with the passed pilemap

Member Data Documentation

template<typename Idx, typename T>
SMLNode<Idx,T>* sutil::CMappedList< Idx, T >::back_
protectedinherited

Pointer to the tail/back/dangling-end of the list

template<typename Idx, typename T>
bool sutil::CMappedList< Idx, T >::flag_is_sorted_
protectedinherited

Whether the list is sorted or not

template<typename Idx, typename T>
SMLNode<Idx,T>* sutil::CMappedList< Idx, T >::front_
protectedinherited

Mapped List Data


Pointer to the head/front/insertion-end of the list

template<typename Idx, typename T>
std::map<Idx, SMLNode<Idx,T>*> sutil::CMappedList< Idx, T >::map_
protectedinherited

The map that will enable Idx based data lookup

template<typename Idx, typename T>
std::map<const T*, std::size_t> sutil::CMappedMultiLevelList< Idx, T >::map_nodeptr2pri_
protected

Maintain a map of the node pointer to the priority levels as well. This allows chaining to find out the pri level even from the index (pri == map_nodeptr2pri_[map_[idx]]) && (pri == map_nodeptr2pri_[nodeptr])

template<typename Idx, typename T>
std::vector<std::vector<T*> > sutil::CMappedMultiLevelList< Idx, T >::mlvec_

Create a node on the mapped list and also insert it into the vector of lists. That way someone can lookup or iterate over the mapped list and can also exploit the structure of the vec<list>

NOTE TODO : Should not keep this public. Resolve this later.

template<typename Idx, typename T>
SMLNode<Idx,T> sutil::CMappedList< Idx, T >::null_
protectedinherited

Pointer to the element obtained with the end() call. Does not exist in the map.

template<typename Idx, typename T>
std::size_t sutil::CMappedMultiLevelList< Idx, T >::pri_levels_
protected

The priority levels this multi-level map has

template<typename Idx, typename T>
std::size_t sutil::CMappedList< Idx, T >::size_
protectedinherited

The size of the MappedList

template<typename Idx, typename T>
std::vector<Idx> sutil::CMappedList< Idx, T >::sorting_order_
protectedinherited

An index that specifies a sort ordering if required


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