|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
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>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. | |
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.
Array). Definition in file tpl_small_vector.H.