Home

stdlist

stdlist is not a standard term in the C++ standard library. The correct name is std::list, a container defined in the <list> header that implements a doubly linked list. std::list stores elements in separate nodes, each linking to the previous and next elements, so the elements are not stored contiguously.

Key features and usage: std::list is a templated class template: std::list<T, Allocator = std::allocator<T>>. It provides bidirectional

Complexity and memory considerations: Insertion or erasure at a given position, given a valid iterator, is typically

When to choose std::list: opt for std::list if you require frequent middle insertions/deletions, stable iterators, or

iterators,
allowing
traversal
in
both
directions.
Common
operations
include
push_back,
push_front,
emplace_back,
emplace_front,
pop_back,
pop_front,
insert,
erase,
clear,
size,
empty,
front,
back,
and
reverse.
It
also
offers
advanced
operations
such
as
splice
(to
move
elements
between
lists
in
constant
time),
merge,
sort,
unique,
remove,
and
remove_if.
The
container
supports
stable
iteration,
and
iterations
remain
valid
across
many
insertions
and
deletions,
except
for
the
erased
elements.
constant
time.
Access
by
index
is
not
supported;
operator[]
is
absent
and
random
access
is
O(n).
Because
each
element
is
allocated
separately,
std::list
incurs
more
memory
overhead
and
poorer
cache
locality
compared
to
contiguous
containers
like
std::vector.
This
makes
list
slower
for
traversal-heavy
workloads,
but
advantageous
when
many
insertions
or
deletions
occur
in
the
middle
of
the
sequence,
or
when
you
need
reliable
iterators
and
references
to
elements.
efficient
splicing
of
existing
elements
between
lists.
For
random
access,
cache-friendly
traversal,
or
fewer
allocations,
other
containers
such
as
std::vector
or
std::forward_list
(singly
linked)
may
be
more
appropriate.