Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_small_vector.H File Reference

Dynamic array with inline storage (Aleph::SmallVector). More...

#include <cstddef>
#include <initializer_list>
#include <iterator>
#include <limits>
#include <memory>
#include <new>
#include <type_traits>
#include <utility>
#include <ah-errors.H>
Include dependency graph for tpl_small_vector.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::SmallVector< T, N >
 Contiguous dynamic array with N elements of inline storage. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Detailed Description

Dynamic array with inline storage (Aleph::SmallVector).

SmallVector<T, N> stores up to N elements inside the object itself — no heap allocation at all — and transparently spills to the heap when it grows past N. It is the classic small-buffer-optimized vector (cf. llvm::SmallVector, boost::container::small_vector), ideal for containers that are usually small: argument lists, adjacency lists of sparse nodes, scratch buffers in hot loops.

Aspect SmallVector<T, N> Array<T> / std::vector
first N appends no allocation heap allocation
element storage inline, then heap always heap
move of heap-mode object O(1) pointer steal O(1)
move of inline-mode object O(n) element moves O(1)

Unlike the MemArray-based containers, SmallVector manages raw storage with placement construction, so T needs no default constructor; move-only types such as std::unique_ptr are supported.

See also
tpl_array.H General-purpose dynamic array (Array).
tpl_memArray.H Low-level contiguous buffer used by Aleph containers.
Author
Leandro Rabindranath Leon

Definition in file tpl_small_vector.H.