CMappedList Tutorial

Issue #127 resolved
brian soe created an issue

Because so much of SCL uses CMappedLists, it would be extremely helpful to have a tutorial that explains the following:

a) Why have a data struct that has the characteristics of a map, vector, and linked-list?

b) How is it like a stl map? How to insert by key, access by key, iterate by sorted key and get first, second of pair, find element by key, sort?

c) How is it like a stl vector? How to insert by index, access by index, push_back, iterate by index?

d) How is it like a linked list?

e) Where are CMappedLists used in SCL and why?

It would be helpful/intuitive if CMappedList had a .first() and .second(), to mimick the stl map pair behavior.

Comments (15)

  1. Samir Menon repo owner

    a) Why have a data struct that has the characteristics of a map, vector, and linked-list?

    Also used as a tree, ring (future, and graph (future). Primary use to iterate over rigid bodies Tree : Compute Jacobians, transforms efficiently Vector : It is NOT a vector. List : Iterate over links to log/print data, read state Map : Random access. Eg. Apply external forces to a link.

    b) How is it like a stl map? How to insert by key, access by key, iterate by sorted key and get first, second of pair, find element by key, sort?

    It encapsulates an stl map. create(), insert() (see code comments) Key = !iterator. Value = *iterator.

    c) How is it like a stl vector? How to insert by index, access by index, push_back, iterate by index?

    It is NOT like a vector. It is a list. Vectors don't guarantee that a pointer will always point to the same memory location. This is bad for high performance direct memory access.

    d) How is it like a linked list?

    It encapsulates a linked list.

    e) Where are CMappedLists used in SCL and why? $ cd src/scl $ grep -R CMappedList *

  2. brian soe reporter

    Thanks, I will do that. One more question. Why have an access by index [ ], if it is not like a vector?

  3. Log in to comment