|
nngn
|
Fixed-size vector with an embedded free list. More...
#include <static_vector.h>


Classes | |
| union | entry |
Public Member Functions | |
| ~static_vector (void)=default | |
| static_vector (void)=default | |
| Constructs an empty vector. | |
| static_vector (std::size_t n) | |
Constructs an empty vector with capacity n. | |
| std::size_t | size (void) const |
| Calculates the true size (excluding the entries in the free list). | |
| std::size_t | n_free (void) const |
| Calculates the number of entries in the free list. | |
| bool | full (void) const |
| Checks if the vector is full (i.e. | |
| void | set_capacity (std::size_t c) |
| Changes the total number of items of the vector can hold. | |
| T & | insert (T t) |
| Inserts an element in the first free position. | |
| template<typename ... Ts> | |
| T & | emplace (Ts &&...ts) |
| Emplace an element in the first free position. | |
| void | erase (T *p) |
Removes element p from the vector. | |
| void | erase (iterator it) |
Removes the element at *it from the vector. | |
Private Types | |
| using | vector_type = std::vector<T> |
Private Attributes | |
| entry * | free_head = {} |
| Pointer to the first entry in the free list. | |
Fixed-size vector with an embedded free list.
Provides constant time insertion and removal. The free list is kept in the first sizeof(std::uintptr_t) bytes of T. Adding elements when the vector is full results in undefined behavior, but the size can be changed using set_capacity.
|
private |
|
default |
|
default |
Constructs an empty vector.
set_capacity must be called before items are added.
|
inlineexplicit |
Constructs an empty vector with capacity n.

| T & nngn::static_vector< T >::emplace | ( | Ts &&... | ts | ) |
Emplace an element in the first free position.
Complexity: O(1).

| void nngn::static_vector< T >::erase | ( | iterator | it | ) |
Removes the element at *it from the vector.
Complexity: O(1).

| void nngn::static_vector< T >::erase | ( | T * | p | ) |
Removes element p from the vector.
Complexity: O(1).


| bool nngn::static_vector< T >::full | ( | void | ) | const |
Checks if the vector is full (i.e.
no more items can be added).

|
inline |
Inserts an element in the first free position.
Complexity: O(1).

| std::size_t nngn::static_vector< T >::n_free | ( | void | ) | const |
Calculates the number of entries in the free list.
| void nngn::static_vector< T >::set_capacity | ( | std::size_t | c | ) |
Changes the total number of items of the vector can hold.
Previous data are lost.


| std::size_t nngn::static_vector< T >::size | ( | void | ) | const |
Calculates the true size (excluding the entries in the free list).
Complexity: O(n_free()).

|
private |
Pointer to the first entry in the free list.