std - C++ standard lib: Achieving constant time remove from linked list -


I would like to use standard library data structures (because one can easily override the allocator) one (probably doubled) A list that allows continuous time taking action An element is given an indication.

Is this functionality built into a standard library data structure? Imagine the following list: elementB, elementB, elementC]

Deleting element B has constant time in the shape of the list, if someone can say something for this effect :

  elementB.previous.next = pointer_to (elementC)  

... or should I make my own linked list to get it?

Built-in std :: list supports constant-time deletion elements Quote:

The lists are sequence containers that repeat the continuous time and the deleted tasks anywhere in the sequence, and walk in both directions.

Implementation is actually a double-linked list:

List containers are applied as doubled-linked lists; In dip-linked lists, each element can store in separate and unrelated storage locations. This sequence is kept by combining with each element of the link of the preceding element and after this there is a link for the element.

Std :: list :: iterator = / * Find an element / /; // Remove the element in continuous time mylist.erase (this);


Comments