Generic collections of objects for embedded devices.
Main docs: Home | Lists | Maps | Queues | Sets | Vectors | Utilities | Using items with multiple containers
Submodules | |
C API | |
Lists | |
Maps | |
Queues | |
Sets | |
Utilities | |
Vectors | |
Namespaces | |
namespace | pw |
The Pigweed namespace. | |
Classes | |
class | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque > |
class | pw::containers::internal::GenericAATree |
class | pw::containers::internal::KeyedAATree< K > |
class | pw::containers::internal::AATree< K, V > |
class | pw::containers::internal::AATree< K, V >::Item |
class | pw::containers::internal::AATree< K, V >::Pair |
An extension of Item that includes storage for a key. More... | |
Macros | |
#define | PW_VARIABLE_LENGTH_ENTRY_QUEUE_HEADER_SIZE_UINT32 (3) |
#define | _PW_VAR_QUEUE_SIZE_UINT32(max_size_bytes) |
#define | _PW_VAR_QUEUE_DATA_SIZE_UINT32(max_size_bytes) ((_PW_VAR_QUEUE_DATA_SIZE_BYTES(max_size_bytes) + 3 /* round up */) / 4) |
#define | _PW_VAR_QUEUE_DATA_SIZE_BYTES(max_size_bytes) |
#define | _PW_VAR_QUEUE_CHECK_SIZE(max_size_bytes) |
Typedefs | |
template<typename ValueType , typename SizeType , size_t kCapacity = containers::internal::kGenericSized> | |
using | pw::BasicInlineDeque = containers::internal::BasicInlineDequeImpl< ValueType, containers::internal::CountAndCapacity< SizeType >, kCapacity > |
template<typename T , size_t kCapacity = containers::internal::kGenericSized> | |
using | pw::InlineDeque = BasicInlineDeque< T, uint16_t, kCapacity > |
template<size_t kCapacity> | |
using | pw::BasicInlineQueue< ValueType, SizeType, containers::internal::kGenericSized >::Derived = BasicInlineQueue< value_type, size_type, kCapacity > |
using | pw::containers::internal::GenericAATree::iterator = AATreeIterator<> |
using | pw::containers::internal::KeyedAATree< K >::Key = K |
using | pw::containers::internal::KeyedAATree< K >::Compare = Function< bool(Key, Key)> |
using | pw::containers::internal::KeyedAATree< K >::GetKey = Function< Key(const AATreeItem &)> |
using | pw::containers::internal::AATree< K, V >::Base = KeyedAATree< K > |
using | pw::containers::internal::AATree< K, V >::Key = typename Base::Key |
using | pw::containers::internal::AATree< K, V >::Compare = typename Base::Compare |
using | pw::containers::internal::AATree< K, V >::GetKey = Function< Key(const V &)> |
template<typename T > | |
using | pw::IntrusiveList = containers::future::IntrusiveList< T > |
Functions | |
constexpr | pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::BasicInlineQueue (ConstexprTag constexpr_tag) noexcept |
pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::BasicInlineQueue (size_type count, const_reference value) | |
pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::BasicInlineQueue (size_type count) | |
template<typename InputIterator , typename = containers::internal::EnableIfInputIterator<InputIterator>> | |
pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::BasicInlineQueue (InputIterator start, InputIterator finish) | |
pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::BasicInlineQueue (const std::initializer_list< value_type > &list) | |
pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::BasicInlineQueue (const BasicInlineQueue &other) | |
Copy constructs for matching capacity. | |
template<size_t kOtherCapacity> | |
pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::BasicInlineQueue (const BasicInlineQueue< ValueType, SizeType, kOtherCapacity > &other) | |
pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::BasicInlineQueue (BasicInlineQueue &&other) | |
Move constructs for matching capacity. | |
template<size_t kOtherCapacity> | |
pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::BasicInlineQueue (BasicInlineQueue< ValueType, SizeType, kOtherCapacity > &&other) | |
template<typename T , typename = containers::internal::EnableIfIterable<T>> | |
pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::BasicInlineQueue (const T &other) | |
BasicInlineQueue & | pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::operator= (const std::initializer_list< value_type > &list) |
BasicInlineQueue & | pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::operator= (const BasicInlineQueue &other) |
Copy assigns from matching capacity. | |
template<size_t kOtherCapacity> | |
BasicInlineQueue & | pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::operator= (const BasicInlineQueue< ValueType, SizeType, kOtherCapacity > &other) |
BasicInlineQueue & | pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::operator= (BasicInlineQueue &&other) |
Move assigns from matching capacity. | |
template<size_t kOtherCapacity> | |
BasicInlineQueue & | pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::operator= (BasicInlineQueue< ValueType, SizeType, kOtherCapacity > &&other) |
template<typename T , typename = containers::internal::EnableIfIterable<T>> | |
BasicInlineQueue & | pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::operator= (const T &other) |
static constexpr size_type | pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::max_size () |
static constexpr size_type | pw::BasicInlineQueue< ValueType, SizeType, kCapacity >::capacity () |
Deque & | pw::BasicInlineQueue< ValueType, SizeType, containers::internal::kGenericSized >::deque () |
const Deque & | pw::BasicInlineQueue< ValueType, SizeType, containers::internal::kGenericSized >::deque () const |
reference | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::at (size_type index) |
const_reference | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::at (size_type index) const |
reference | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::operator[] (size_type index) |
const_reference | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::operator[] (size_type index) const |
std::pair< span< const value_type >, span< const value_type > > | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::contiguous_data () const |
std::pair< span< value_type >, span< value_type > > | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::contiguous_data () |
iterator | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::begin () noexcept |
const_iterator | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::begin () const noexcept |
const_iterator | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::cbegin () const noexcept |
iterator | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::end () noexcept |
const_iterator | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::end () const noexcept |
const_iterator | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::cend () const noexcept |
bool | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::full () const noexcept |
void | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::clear () noexcept |
void | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::push_overwrite (const value_type &value) |
void | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::push_overwrite (value_type &&value) |
template<typename... Args> | |
void | pw::containers::internal::BasicInlineQueueImpl< Derived, Deque >::emplace_overwrite (Args &&... args) |
constexpr | pw::containers::internal::GenericAATree::GenericAATree (bool unique_keys) |
pw::containers::internal::GenericAATree::~GenericAATree () | |
Destructor. | |
pw::containers::internal::GenericAATree::GenericAATree (const GenericAATree &)=delete | |
GenericAATree & | pw::containers::internal::GenericAATree::operator= (const GenericAATree &)=delete |
constexpr bool | pw::containers::internal::GenericAATree::unique_keys () const |
void | pw::containers::internal::GenericAATree::SetRoot (AATreeItem *item) |
Sets the tree's root item. | |
constexpr iterator | pw::containers::internal::GenericAATree::begin () noexcept |
Returns a pointer to the first item, if any. | |
constexpr iterator | pw::containers::internal::GenericAATree::end () noexcept |
Returns a pointer to the last item, if any. | |
constexpr bool | pw::containers::internal::GenericAATree::empty () const |
Returns whether the tree has zero items or not. | |
size_t | pw::containers::internal::GenericAATree::size () const |
Returns the number of items in the tree. | |
constexpr size_t | pw::containers::internal::GenericAATree::max_size () const noexcept |
void | pw::containers::internal::GenericAATree::clear () |
iterator | pw::containers::internal::GenericAATree::erase_one (AATreeItem &item) |
iterator | pw::containers::internal::GenericAATree::erase_range (AATreeItem &first, AATreeItem &last) |
iterator | pw::containers::internal::GenericAATree::erase_range (iterator first, iterator last) |
void | pw::containers::internal::GenericAATree::swap (GenericAATree &other) |
Exchanges this tree's items with the other tree's items. | |
constexpr | pw::containers::internal::KeyedAATree< K >::KeyedAATree (bool unique_keys, Compare &&compare, GetKey &&get_key) |
void | pw::containers::internal::KeyedAATree< K >::SetCompare (Compare &&compare) |
void | pw::containers::internal::KeyedAATree< K >::SetGetKey (GetKey &&get_key) |
std::pair< iterator, bool > | pw::containers::internal::KeyedAATree< K >::insert (AATreeItem &item) |
template<class Iterator > | |
void | pw::containers::internal::KeyedAATree< K >::insert (Iterator first, Iterator last) |
size_t | pw::containers::internal::KeyedAATree< K >::erase_all (Key key) |
void | pw::containers::internal::KeyedAATree< K >::merge (KeyedAATree< K > &other) |
size_t | pw::containers::internal::KeyedAATree< K >::count (Key key) |
iterator | pw::containers::internal::KeyedAATree< K >::find (Key key) |
std::pair< iterator, iterator > | pw::containers::internal::KeyedAATree< K >::equal_range (Key key) |
iterator | pw::containers::internal::KeyedAATree< K >::lower_bound (Key key) |
iterator | pw::containers::internal::KeyedAATree< K >::upper_bound (Key key) |
constexpr | pw::containers::internal::AATree< K, V >::Pair::Pair (Key key) |
constexpr Key | pw::containers::internal::AATree< K, V >::Pair::key () const |
constexpr bool | pw::containers::internal::AATree< K, V >::Pair::operator< (const Pair &rhs) |
constexpr | pw::containers::internal::AATree< K, V >::AATree (bool unique_keys, Compare &&compare, GetKey &&get_key) |
Variables | |
GetKey | pw::containers::internal::AATree< K, V >::get_key_ |
#define _PW_VAR_QUEUE_CHECK_SIZE | ( | max_size_bytes | ) |
#define _PW_VAR_QUEUE_DATA_SIZE_BYTES | ( | max_size_bytes | ) |
#define _PW_VAR_QUEUE_SIZE_UINT32 | ( | max_size_bytes | ) |
#define PW_VARIABLE_LENGTH_ENTRY_QUEUE_HEADER_SIZE_UINT32 (3) |
The size of the InlineVarLenEntryQueue
header, in uint32_t
elements. This header stores the buffer length and head and tail offsets.
The underlying uint32_t
array of a InlineVarLenEntryQueue
must be larger than this size.
using pw::InlineDeque = typedef BasicInlineDeque<T, uint16_t, kCapacity> |
The InlineDeque
class is similar to the STL's double ended queue (std::deque
), except it is backed by a fixed-size buffer. InlineDeque
's must be declared with an explicit maximum size (e.g. InlineDeque<int, 10>>
) but deques can be used and referred to without the max size template parameter (e.g. InlineDeque<int>
).
To allow referring to a pw::InlineDeque
without an explicit maximum size, all InlineDeque
classes inherit from a RawStorage
class, which in turn inherits from InlineDeque<T>
, which stores the maximum size in a variable. This allows InlineDeque
s to be used without having to know their maximum size at compile time. It also keeps code size small since function implementations are shared for all maximum sizes.
An InlineDeque
cannot increase its capacity. Any operations that would exceed the capacity (e.g. assign
, push_back
, push_front
) fail a PW_ASSERT
. Avoid this by choosing a large enough capacity or checking full()
before adding items.
using pw::IntrusiveList = typedef containers::future::IntrusiveList<T> |
A doubly-linked intrusive list.
IntrusiveList<T> is a handle to access and manipulate the list, and IntrusiveList<T>::Item is the type from which the base class items must derive.
As a doubly-linked list, operations such as removal are O(1) in time, and the list may be iterated in either direction. However, the overhead needed is 2*sizeof(T*)
.
This class is modeled on std::list
, with the following differences:
iterator
s and not const_iterator
s:erase
is provided that takes a direct reference to an item.T | Type of intrusive items stored in the list. |
|
inlineconstexpr |
Constructs an empty AA tree.
unique_keys | Indicates if this tree requires unique keys or allows duplicate keys. |
|
inline |
Move constructs for mismatched capacity.
Note that this will result in a crash if kOtherCapacity < size()
.
|
inline |
Copy constructs for mismatched capacity.
Note that this will result in a crash if kOtherCapacity < size()
.
void pw::containers::internal::GenericAATree::clear | ( | ) |
Removes all items from the tree and leaves it empty.
The items themselves are not destructed.
size_t pw::containers::internal::KeyedAATree< K >::count | ( | Key | key | ) |
Returns the number of items in the tree with the given key.
If the tree requires unique keys, this simply 0 or 1.
std::pair< GenericAATree::iterator, GenericAATree::iterator > pw::containers::internal::KeyedAATree< K >::equal_range | ( | Key | key | ) |
Returns a pair of items where the first points to the item with the smallest key that is not less than the given key, and the second points to the item with the smallest key that is greater than the given key.
size_t pw::containers::internal::KeyedAATree< K >::erase_all | ( | Key | key | ) |
Removes items that match the given key
, and returns an iterator to the item after the removed items and the number of items removed.
iterator pw::containers::internal::GenericAATree::erase_one | ( | AATreeItem & | item | ) |
Removes an item from the tree and returns an iterator to the item after the removed item.
The items themselves are not destructed.
iterator pw::containers::internal::GenericAATree::erase_range | ( | AATreeItem & | first, |
AATreeItem & | last | ||
) |
Removes the items from first, inclusive, to last, exclusive from the tree and returns an iterator to the item after the last removed item.
The items themselves are not destructed.
iterator pw::containers::internal::GenericAATree::erase_range | ( | iterator | first, |
iterator | last | ||
) |
Removes the items from first, inclusive, to last, exclusive from the tree
and returns an iterator to the item after the last removed item.
The items themselves are not destructed.
GenericAATree::iterator pw::containers::internal::KeyedAATree< K >::find | ( | Key | key | ) |
Returns a pointer to an item with the given key, or null if the tree does not contain such an item.
|
inlineexplicitconstexpr |
Constructs an empty AA tree.
unique_keys | Indicates if this tree requires unique keys or allows duplicate keys. |
std::pair< GenericAATree::iterator, bool > pw::containers::internal::KeyedAATree< K >::insert | ( | AATreeItem & | item | ) |
Attempts to add the given item to the tree.
The item will be added if the tree does not already contain an item with the given item's key or if the tree does not require unique keys.
true
, or a pointer to the existing item with same key and false
. void pw::containers::internal::KeyedAATree< K >::insert | ( | Iterator | first, |
Iterator | last | ||
) |
Inserts each item from first
, inclusive, to last
, exclusive. If the tree does not all duplicates and an equivalent item is already in the tree, the item is ignored.
|
inlineexplicitconstexpr |
Constructs an empty AA tree.
unique_keys | Indicates if this tree requires unique keys or allows duplicate keys. |
GenericAATree::iterator pw::containers::internal::KeyedAATree< K >::lower_bound | ( | Key | key | ) |
Returns the item in the tree with the smallest key that is greater than or equal to the given key, or null if the tree is empty.
|
inlineconstexprnoexcept |
Returns how many items can be added.
As an intrusive container, this is effectively unbounded.
void pw::containers::internal::KeyedAATree< K >::merge | ( | KeyedAATree< K > & | other | ) |
Splices items from the other
tree into this one.
The receiving tree's Compare
and GetKey
functions are used when inserting items.
|
inline |
Move assigns from mismatched capacity.
Note that this will result in a crash if kOtherCapacity < size()
.
|
inline |
Copy assigns from mismatched capacity.
Note that this will result in a crash if kOtherCapacity < size()
.
GenericAATree::iterator pw::containers::internal::KeyedAATree< K >::upper_bound | ( | Key | key | ) |
Returns the item in the tree with the smallest key that is strictly greater than the given key, or null if the tree is empty.