My question is very simple, can one using C++, implement a link-list data structure without using pointers (next nodes)? To further qualify my question, I'm mean can one create a Linked-List data structure using only class instantiations.
A common node definition might be like so:
template<typename T>
struct node
{
T t;
node<T>* next;
node<T>* prev;
};
I'm aware of std::list
etc, I'm just curious to know if its possible or not - and if so how? Code examples will be greatly appreciated.
More clarifications:
- Insertions should be O(1).
- Traversal should be no more than O(n).
- A real node and a null node should be differentiable.
- The size of the linked-list should only be limited by the amount of memory available.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…