A
Amit
Greetings All.
One of the usages that I need is accessing the contents of the container
that I am using in level order( which would mean breadth- first search
approach for a binary tree) as compared to the default depth-first search
approach that happens when we traverse using the default iterator for a set
or a map, when using either the less/greater comparator function object.
Would anyone know, how I can access the elements of a set or a map in a
level order? I tried specifying the comparator object that I want, but
having it sorted as well as getting what I want (level order access) is not
working out.
Further more, if I want all level order elements of that container(either
set or map) maintained via a linked list for traversing, is there an easy
way to get it done ? This would of course mean deriving a custom container
from a Set and adding another pointer that points to a peer Node. I know
there is a _Tree template class(which is a red black tree), the class
template which is used for deriving Map and Set . Maybe I can use that
directly, but I am still not sure how I can still get level order access
using that.
Thanks.
One of the usages that I need is accessing the contents of the container
that I am using in level order( which would mean breadth- first search
approach for a binary tree) as compared to the default depth-first search
approach that happens when we traverse using the default iterator for a set
or a map, when using either the less/greater comparator function object.
Would anyone know, how I can access the elements of a set or a map in a
level order? I tried specifying the comparator object that I want, but
having it sorted as well as getting what I want (level order access) is not
working out.
Further more, if I want all level order elements of that container(either
set or map) maintained via a linked list for traversing, is there an easy
way to get it done ? This would of course mean deriving a custom container
from a Set and adding another pointer that points to a peer Node. I know
there is a _Tree template class(which is a red black tree), the class
template which is used for deriving Map and Set . Maybe I can use that
directly, but I am still not sure how I can still get level order access
using that.
Thanks.