STL linked list w/multiple entries?

J

Jim Langston

Is there an STL linked list that allowes multiple entries per "level"?

I'm suspecting no and will have to create my own using some STL container(s)
wrapped in a class.

What I'm working on for the heck of it is mapping routers on the internet
from my computer's point of view. That is, when I do a tracert (traceroute
in linux) I get a list of routers. I want to put these in a container so
that I can view them graphically. For a simple tracert a single list would
suffice. :But for multiple tracerts as data is gathered one router will
connect to more than one other router, and there are times when one router
may be connected from more than one router.

I'm probably going to do what I normally do with this type of data, a map of
a class that contains maps. I.E. something like:

class Foo
{
Foo* Parent;
std::list<Foo> Data;
}

then I'll use a std::map<Foo*> or such to be able to find quickly which Foo
the entry is in. I just don't like having to use naked pointers too much,
especially since serializing it for saving will be a pain.
 
K

Kai-Uwe Bux

Jim said:
Is there an STL linked list that allowes multiple entries per "level"?

Well, not in the standard library.

I'm suspecting no and will have to create my own using some STL
container(s) wrapped in a class.
Yep.


What I'm working on for the heck of it is mapping routers on the internet
from my computer's point of view. That is, when I do a tracert
(traceroute
in linux) I get a list of routers. I want to put these in a container so
that I can view them graphically. For a simple tracert a single list
would
suffice. :But for multiple tracerts as data is gathered one router will
connect to more than one other router, and there are times when one router
may be connected from more than one router.

I'm probably going to do what I normally do with this type of data, a map
of
a class that contains maps. I.E. something like:

class Foo
{
Foo* Parent;
std::list<Foo> Data;
}

Warning: the above has undefined behavior since Foo is incomplete at the
point where std::list<Foo> is used to declare Data. The code may or may not
compile and if it compiles, it may or may not work as expected.

then I'll use a std::map<Foo*> or such to be able to find quickly which
Foo
the entry is in. I just don't like having to use naked pointers too much,
especially since serializing it for saving will be a pain.

It looks as though you have to store a graph-like data structure. Maybe some
graph library can be used?


Best

Kai-Uwe Bux
 
J

Jerry Coffin

Is there an STL linked list that allowes multiple entries per "level"?

I'm suspecting no and will have to create my own using some STL container(s)
wrapped in a class.

What I'm working on for the heck of it is mapping routers on the internet
from my computer's point of view. That is, when I do a tracert (traceroute
in linux) I get a list of routers. I want to put these in a container so
that I can view them graphically. For a simple tracert a single list would
suffice. :But for multiple tracerts as data is gathered one router will
connect to more than one other router, and there are times when one router
may be connected from more than one router.

I'd take a look at the Boost graph library. It's specifically intended
to support situations like yours.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top