473,554 Members | 2,324 Online

# a stl list of list with jump back

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
3 1709
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
> 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
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 thread has been closed and replies have been disabled. Please start a new discussion.