- edited description
- marked as minor
-
assigned issue to
CMappedList Tutorial
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)
-
reporter -
reporter - edited description
-
reporter - edited description
-
repo owner -
assigned issue to
-
assigned issue to
-
repo owner @bsoe Very good questions. I'll answer them. Please update the wiki and close the bug.
Read comments: https://github.com/samirmenon/sUtil/blob/master/src/sutil/CMappedList.hpp
And go through test cases: https://github.com/samirmenon/sUtil/blob/master/applications-linux/sutil_test/test-mappedlist.cpp https://github.com/samirmenon/sUtil/blob/master/applications-linux/sutil_test/test-mapped-tree.cpp
-
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 *
-
repo owner It would be helpful/intuitive if CMappedList had a .first() and .second(), to mimick the stl map pair behavior.
- I think .first() and .second() is a terrible notation. It should have been .key() and .value()
If you feel strongly about it, open a separate bug in sutil. This is not a part of scl. https://github.com/samirmenon/sUtil/issues?direction=desc&sort=created&state=open
-
reporter Thanks, I will do that. One more question. Why have an access by index [ ], if it is not like a vector?
-
reporter Added a Wikipage under how to. It need some additional explanation.
-
reporter - changed status to resolved
-
reporter - changed status to open
Re-assigning to Samir to fill in the info I did not fully understand.
-
reporter -
assigned issue to
-
assigned issue to
-
repo owner Where do I fill in more information?
-
repo owner -
assigned issue to
-
assigned issue to
-
reporter - changed status to resolved
- Log in to comment