By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,412 Members | 978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,412 IT Pros & Developers. It's quick & easy.

a stl list of list with jump back

P: n/a
Hi, i need to create a list of list in STL where each element can move
from a given list level to the adjacent list.

i.e.

| -> x -> y -> z

| -> a -> b

can be modified to

| -> x -> y

| -> z -> a -> b

the idea is that element can jump back the head of each list and then
acces the other adjacent list (below). Space is not an issue: I accept
the cost of the back pointer. But operation should be done in O(1).

What is the best way to describe this in STL?
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hello Antonio,
Hi, i need to create a list of list in STL where each element can move
from a given list level to the adjacent list.

i.e.

| -> x -> y -> z

| -> a -> b

can be modified to

| -> x -> y

| -> z -> a -> b

the idea is that element can jump back the head of each list and then
acces the other adjacent list (below). Space is not an issue: I accept
the cost of the back pointer. But operation should be done in O(1).

What is the best way to describe this in STL?


I dont even understand what you are trying to do here. Can you provide a
better example?

thanks
bharat kari
Jul 23 '05 #2

P: n/a
> the idea is that element can jump back the head of each list and then
acces the other adjacent list (below). Space is not an issue: I accept
the cost of the back pointer. But operation should be done in O(1).

What is the best way to describe this in STL?


Just use one or more list of elements.
NOT lists of lists.

You will find that list has a member function call splice() (and there are
several versions of it), which allows you to splice elements from one list
into another or even whole lists and specify where it insert element(s).
I think with 2+ list objects you will find that splice() allows you to
transfer elements

Stephen Howe
Jul 23 '05 #3

P: n/a
agu
Antonio Gulli wrote:
Hi, i need to create a list of list in STL where each element can move
from a given list level to the adjacent list.

i.e.

| -> x -> y -> z

| -> a -> b

can be modified to

| -> x -> y

| -> z -> a -> b

the idea is that element can jump back the head of each list and then
acces the other adjacent list (below). Space is not an issue: I accept
the cost of the back pointer. But operation should be done in O(1).

What is the best way to describe this in STL?


The idea is to implement in efficient way
http://magna.cs.ucla.edu/~hxwang/stream/karp-tods03.pdf
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.