Wiki

Clone wiki

scl-manips-group / howdoi / CMappedList

What is a CMappedList

CMappedList is a data structure that has the properties of several stl data structures:

  • map
  • linked-list
  • tree
  • ring (future feature)
  • graph (future feature)

Why is this useful?

For robot composed of rigid bodies, each link has a parent link. A linked-list allows simple iteration from the base frame, to each subsequent link frame. This is useful for computing transformation matrices, or printing/logging data. Links can also be access by their key (link name), for example when selecting a link with the mouse.

CMappedTree

A robot may have multiple links attached to a parent link (e.g. arms on a body). A CMappedTree adds the functionality of a tree. It inherits from CMappedList.

Map

Map access is done via the .at(key) operator. The [ ] operator provides access by index, but is primarily for debugging. Accessing a tree by index is a bit odd.

Insert

Create() copies the given element, inserts the copied element into the list and returns the pointer to the copied element.

virtual T* create(const Idx & key, const T& value, const bool insert_at_start=true);

Insert() 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. will inserted using create().

virtual T* create(const Idx & key, const T& value, const bool insert_at_start=true);

How is insert different if it also has a copied element?

Iterating

CMappedList<string, CRigidBody>::const_iterator it,ite;
for(it = robot_data.begin(), ite = robot_data.end(); it!=ite; ++it)
{
	cout << !it << endl; //key
	cout << *it << endl; //value
}

In the future, .key() and .value() can be used, rather than ! and *.

Performance

Comparison to STL data structures:

TODO

Updated