a stl list of list with jump back

A

Antonio Gulli

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?
 
B

Bharat Karia

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
 
S

Stephen Howe

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
 
A

agu

Antonio said:
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
 

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,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top