pw_containers#

The pw_containers module provides embedded-friendly container classes.

pw::Vector#

The Vector class is similar to std::vector, except it is backed by a fixed-size buffer. Vectors must be declared with an explicit maximum size (e.g. Vector<int, 10>) but vectors can be used and referred to without the max size template parameter (e.g. Vector<int>).

To allow referring to a pw::Vector without an explicit maximum size, all Vector classes inherit from the generic Vector<T>, which stores the maximum size in a variable. This allows Vectors 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.

Non-trivially-destructible, self-referencing types

pw::Vector is not safe to use with non-trivially-destructible, self-referencing types. See b/313899658.

pw::InlineDeque#

template<typename T, size_t kCapacity = containers::internal::kGenericSized>
using pw::InlineDeque = 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 the BasicInlineDequeStorage class, which in turn inherits from InlineDeque<T>, which stores the maximum size in a variable. This allows InlineDeques 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.

pw::InlineQueue#

template<typename T, size_t kCapacity = containers::internal::kGenericSized>
using pw::InlineQueue = BasicInlineQueue<T, uint16_t, kCapacity>#

The InlineQueue class is similar to std::queue<T, std::deque>, except it is backed by a fixed-size buffer. InlineQueue’s must be declared with an explicit maximum size (e.g. InlineQueue<int, 10>>) but deques can be used and referred to without the max size template parameter (e.g. InlineQueue<int>).

pw::InlineQueue is wrapper around pw::InlineDeque with a simplified API and push_overwrite() & emplace_overwrite() helpers.

pw::InlineVarLenEntryQueue#

A InlineVarLenEntryQueue is a queue of inline variable-length binary entries. It is implemented as a ring (circular) buffer and supports operations to append entries and overwrite if necessary. Entries may be zero bytes up to the maximum size supported by the queue.

The InlineVarLenEntryQueue has a few interesting properties.

  • Data and metadata are stored inline in a contiguous block of uint32_t-aligned memory.

  • The data structure is trivially copyable.

  • All state changes are accomplished with a single update to a uint32_t. The memory is always in a valid state and may be parsed offline.

This data structure is a much simpler version of pw::ring_buffer::PrefixedEntryRingBuffer . Prefer this sized-entry ring buffer to PrefixedEntryRingBuffer when:

  • A simple ring buffer of variable-length entries is needed. Advanced features like multiple readers and a user-defined preamble are not required.

  • A consistent, parsable, in-memory representation is required (e.g. to decode the buffer from a block of memory).

  • C support is required.

InlineVarLenEntryQueue is implemented in C and provides complete C and C++ APIs. The InlineVarLenEntryQueue C++ class is structured similarly to pw::InlineQueue and pw::Vector.

Example#

Queues are declared with their max size (InlineVarLenEntryQueue<kMaxSize>) but may be used without specifying the size (InlineVarLenEntryQueue<>&).

// Declare a queue with capacity sufficient for one 10-byte entry or
// multiple smaller entries.
pw::InlineVarLenEntryQueue<10> queue;

// Push an entry, asserting if the entry does not fit.
queue.push(queue, data)

// Use push_overwrite() to push entries, overwriting older entries
// as needed.
queue.push_overwrite(queue, more_data)

// Remove an entry.
queue.pop();

Alternately, a InlineVarLenEntryQueue may be initialized in an existing uint32_t array.

// Initialize a InlineVarLenEntryQueue.
uint32_t buffer[32];
auto& queue = pw::InlineVarLenEntryQueue<>::Init(buffer);

// Largest supported entry is 114 B (13 B overhead + 1 B prefix)
assert(queue.max_size_bytes() == 114u);

// Write data
queue.push_overwrite(data);

A InlineVarLenEntryQueue may be declared and initialized in C with the PW_VARIABLE_LENGTH_ENTRY_QUEUE_DECLARE macro.

// Declare a queue with capacity sufficient for one 10-byte entry or
// multiple smaller entries.
PW_VARIABLE_LENGTH_ENTRY_QUEUE_DECLARE(queue, 10);

// Push an entry, asserting if the entry does not fit.
pw_InlineVarLenEntryQueue_Push(queue, "12345", 5);

// Use push_overwrite() to push entries, overwriting older entries
// as needed.
pw_InlineVarLenEntryQueue_PushOverwrite(queue, "abcdefg", 7);

// Remove an entry.
pw_InlineVarLenEntryQueue_Pop(queue);

Alternately, a InlineVarLenEntryQueue may be initialized in an existing uint32_t array.

// Initialize a InlineVarLenEntryQueue.
uint32_t buffer[32];
pw_InlineVarLenEntryQueue_Init(buffer, 32);

// Largest supported entry is 114 B (13 B overhead + 1 B prefix)
assert(pw_InlineVarLenEntryQueue_MaxSizeBytes(buffer) == 114u);

// Write some data
pw_InlineVarLenEntryQueue_PushOverwrite(buffer, "123", 3);

Queue vs. deque#

This module provides InlineVarLenEntryQueue, but no corresponding InlineVarLenEntryDeque class. Following the C++ Standard Library style, the deque class would provide push_front() and pop_back() operations in addition to push_back() and pop_front() (equivalent to a queue’s push() and pop()).

There is no InlineVarLenEntryDeque class because there is no efficient way to implement push_front() and pop_back(). These operations would necessarily be O(n), since each entry knows the position of the next entry, but not the previous, as in a single-linked list. Given that these operations would be inefficient and unlikely to be used, they are not implemented, and only a queue class is provided.

API Reference#

C++#

template<size_t kMaxSizeBytes = containers::internal::kGenericSized>
using InlineVarLenEntryQueue = BasicInlineVarLenEntryQueue<std::byte, kMaxSizeBytes>#

Variable-length entry queue that uses std::byte for the byte type.

template<typename T>
class BasicInlineVarLenEntryQueue<T, containers::internal::kGenericSized>#

Variable-length entry queue class template for any byte type (e.g. std::byte or uint8_t).

BasicInlineVarLenEntryQueue instances are declared with their capacity / max single entry size (BasicInlineVarLenEntryQueue<char, 64>), but may be referred to without the size (BasicInlineVarLenEntryQueue<char>&).

Public Functions

inline Entry front() const#

Returns the first entry in the queue.

inline const_iterator begin() const#

Returns an iterator to the start of the InlineVarLenEntryQueue.

inline const_iterator end() const#

Returns an iterator that points past the end of the queue.

inline bool empty() const#

Returns true if the InlineVarLenEntryQueue is empty, false if it has at least one entry.

inline size_type size() const#

Returns the number of variable-length entries in the queue. This is O(n) in the number of entries in the queue.

inline size_type size_bytes() const#

Returns the combined size in bytes of all entries in the queue, excluding metadata. This is O(n) in the number of entries in the queue.

inline size_type max_size_bytes() const#

Returns the the maximum number of bytes that can be stored in the queue. This is largest possible value of size_bytes(), and the size of the largest single entry that can be stored in this queue. Attempting to store a larger entry is invalid and results in a crash.

inline span<const T> raw_storage() const#

Underlying storage of the variable-length entry queue. May be used to memcpy the queue.

inline void clear()#

Empties the queue.

inline void push(span<const T> value)#

Appends an entry to the end of the queue.

Pre:

The entry MUST NOT be larger than max_size_bytes().

inline void push_overwrite(span<const T> value)#

Appends an entry to the end of the queue, removing entries with Pop as necessary to make room.

Pre:

The entry MUST NOT be larger than max_size_bytes().

inline void pop()#

Removes the first entry from queue.

Pre:

The queue MUST have at least one entry.

Public Static Functions

template<size_t kArraySize>
static inline BasicInlineVarLenEntryQueue &Init(uint32_t (&array)[kArraySize])#

Initializes a InlineVarLenEntryQueue in place in a uint32_t array. The array MUST be larger than PW_VARIABLE_LENGTH_ENTRY_QUEUE_HEADER_SIZE_UINT32 (3) elements.

static inline BasicInlineVarLenEntryQueue &Init(uint32_t array[], size_t array_size_uint32)#

Initializes a InlineVarLenEntryQueue in place in a uint32_t array. The array MUST be larger than PW_VARIABLE_LENGTH_ENTRY_QUEUE_HEADER_SIZE_UINT32 (3) elements.

class Entry#

Refers to an entry in-place in the queue. Entries may be discontiguous.

Public Functions

inline std::pair<span<const value_type>, span<const value_type>> contiguous_data() const#

Entries may be stored in up to two segments, so this returns spans refering to both portions of the entry. If the entry is contiguous, the second span is empty.

inline size_type copy(T *dest, size_type count) const#

Copies the contents of the entry to the provided buffer. The entry may be split into two regions; this serializes it into one buffer.

Copying with copy() is likely more efficient than an iterator-based copy with std::copy(), since copy() uses one or two memcpy calls instead of copying byte-by-byte.

Parameters:
  • entry – The entry whose contents to copy

  • dest – The buffer into which to copy the serialized entry

  • count – Copy up to this many bytes; must not be larger than the dest buffer, but may be larger than the entry

class iterator#

Iterator for the bytes in an Entry. Entries may be discontiguous, so a pointer cannot serve as an iterator.

class iterator#

Iterator object for a InlineVarLenEntryQueue.

Iterators are invalidated by any operations that change the container or its underlying data (push/pop/init).

C#

typedef uint32_t *pw_InlineVarLenEntryQueue_Handle#

Handle that refers to a InlineVarLenEntryQueue. In memory, the queue is a uint32_t array.

typedef const uint32_t *pw_InlineVarLenEntryQueue_ConstHandle#
static inline void pw_InlineVarLenEntryQueue_Init(uint32_t array[], size_t array_size_uint32)#

Initializes a InlineVarLenEntryQueue in place in a uint32_t array. The array MUST be larger than PW_VARIABLE_LENGTH_ENTRY_QUEUE_HEADER_SIZE_UINT32 (3) elements.

static inline void pw_InlineVarLenEntryQueue_Clear(pw_InlineVarLenEntryQueue_Handle queue)#

Empties the queue.

void pw_InlineVarLenEntryQueue_Push(pw_InlineVarLenEntryQueue_Handle queue, const void *data, uint32_t data_size_bytes)#

Appends an entry to the end of the queue.

Pre:

The entry MUST NOT be larger than max_size_bytes().

void pw_InlineVarLenEntryQueue_PushOverwrite(pw_InlineVarLenEntryQueue_Handle queue, const void *data, uint32_t data_size_bytes)#

Appends an entry to the end of the queue, removing entries with Pop as necessary to make room.

Pre:

The entry MUST NOT be larger than max_size_bytes().

void pw_InlineVarLenEntryQueue_Pop(pw_InlineVarLenEntryQueue_Handle queue)#

Removes the first entry from queue.

Pre:

The queue MUST have at least one entry.

static inline pw_InlineVarLenEntryQueue_Iterator pw_InlineVarLenEntryQueue_Begin(pw_InlineVarLenEntryQueue_ConstHandle queue)#

Returns an iterator to the start of the InlineVarLenEntryQueue.

static inline pw_InlineVarLenEntryQueue_Iterator pw_InlineVarLenEntryQueue_End(pw_InlineVarLenEntryQueue_ConstHandle queue)#

Returns an iterator that points past the end of the queue.

void pw_InlineVarLenEntryQueue_Iterator_Advance(pw_InlineVarLenEntryQueue_Iterator *iterator)#

Advances an iterator to point to the next entry in the queue. It is invalid to call Advance on an iterator equal to the End iterator.

static inline bool pw_InlineVarLenEntryQueue_Iterator_Equal(
const pw_InlineVarLenEntryQueue_Iterator *lhs,
const pw_InlineVarLenEntryQueue_Iterator *rhs,
)#

Compares two iterators for equality.

pw_InlineVarLenEntryQueue_Entry pw_InlineVarLenEntryQueue_GetEntry(const pw_InlineVarLenEntryQueue_Iterator *iterator)#

Dereferences an iterator, loading the entry it points to.

uint32_t pw_InlineVarLenEntryQueue_Entry_Copy(const pw_InlineVarLenEntryQueue_Entry *entry, void *dest, uint32_t count)#

Copies the contents of the entry to the provided buffer. The entry may be split into two regions; this serializes it into one buffer.

Parameters:
  • entry – The entry whose contents to copy

  • dest – The buffer into which to copy the serialized entry

  • count – Copy up to this many bytes; must not be larger than the dest buffer, but may be larger than the entry

static inline uint8_t pw_InlineVarLenEntryQueue_Entry_At(const pw_InlineVarLenEntryQueue_Entry *entry, size_t index)#

Returns the byte at the specified index in the entry. Asserts if index is out-of-bounds.

uint32_t pw_InlineVarLenEntryQueue_Size(pw_InlineVarLenEntryQueue_ConstHandle queue)#

Returns the number of variable-length entries in the queue. This is O(n) in the number of entries in the queue.

uint32_t pw_InlineVarLenEntryQueue_SizeBytes(pw_InlineVarLenEntryQueue_ConstHandle queue)#

Returns the combined size in bytes of all entries in the queue, excluding metadata. This is O(n) in the number of entries in the queue.

static inline uint32_t pw_InlineVarLenEntryQueue_MaxSizeBytes(pw_InlineVarLenEntryQueue_ConstHandle queue)#

Returns the the maximum number of bytes that can be stored in the queue. This is largest possible value of size_bytes(), and the size of the largest single entry that can be stored in this queue. Attempting to store a larger entry is invalid and results in a crash.

static inline uint32_t pw_InlineVarLenEntryQueue_RawStorageSizeBytes(pw_InlineVarLenEntryQueue_ConstHandle queue)#

Returns the size of the raw underlying InlineVarLenEntryQueue storage. This size may be used to copy a InlineVarLenEntryQueue into another 32-bit aligned memory location.

static inline bool pw_InlineVarLenEntryQueue_Empty(pw_InlineVarLenEntryQueue_ConstHandle queue)#

Returns true if the InlineVarLenEntryQueue is empty, false if it has at least one entry.

PW_VARIABLE_LENGTH_ENTRY_QUEUE_DECLARE(variable, max_size_bytes)#

Declares and initializes a InlineVarLenEntryQueue that can hold up to max_size_bytes bytes. max_size_bytes is the largest supported size for a single entry; attempting to store larger entries is invalid and will fail an assertion.

Parameters:
  • variable – variable name for the queue

  • max_size_bytes – the capacity of the queue

PW_VARIABLE_LENGTH_ENTRY_QUEUE_HEADER_SIZE_UINT32#

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.

struct pw_InlineVarLenEntryQueue_Iterator#

Iterator object for a InlineVarLenEntryQueue. Iterators are checked for equality with pw_InlineVarLenEntryQueue_Iterator_Equal() .

Iterators are invalidated by any operations that change the container or its underlying data (push/pop/init).

struct pw_InlineVarLenEntryQueue_Entry#

An entry in the queue. Entries may be stored in up to two segments, so this struct includes pointers to both portions of the entry.

Python#

Decodes the in-memory representation of a sized-entry ring buffer.

pw_containers.inline_var_len_entry_queue.parse(queue: bytes) Iterable[bytes]#

Decodes the in-memory representation of a variable-length entry queue.

Parameters:

queue – The bytes representation of a variable-length entry queue.

Yields:

Each entry in the buffer as bytes.

pw::IntrusiveList#

IntrusiveList provides an embedded-friendly singly-linked intrusive list implementation. An intrusive list is a type of linked list that embeds the “next” pointer into the list object itself. This allows the construction of a linked list without the need to dynamically allocate list entries.

In C, an intrusive list can be made by manually including the “next” pointer as a member of the object’s struct. pw::IntrusiveList uses C++ features to simplify the process of creating an intrusive list. pw::IntrusiveList provides a class that list elements can inherit from. This protects the “next” pointer from being accessed by the item class, so only the pw::IntrusiveList class can modify the list.

Usage#

While the API of pw::IntrusiveList is similar to a std::forward_list, there are extra steps to creating objects that can be stored in this data structure. Objects that will be added to a IntrusiveList<T> must inherit from IntrusiveList<T>::Item. They can inherit directly from it or inherit from it through another base class. When an item is instantiated and added to a linked list, the pointer to the object is added to the “next” pointer of whichever object is the current tail.

That means two key things:

  • An instantiated IntrusiveList<T>::Item will be removed from its corresponding IntrusiveList when it goes out of scope.

  • A linked list item CANNOT be included in two lists. Attempting to do so results in an assert failure.

class Square
   : public pw::IntrusiveList<Square>::Item {
 public:
  Square(unsigned int side_length) : side_length(side_length) {}
  unsigned long Area() { return side_length * side_length; }

 private:
  unsigned int side_length;
};

pw::IntrusiveList<Square> squares;

Square small(1);
Square large(4000);
// These elements are not copied into the linked list, the original objects
// are just chained together and can be accessed via
// `IntrusiveList<Square> squares`.
squares.push_back(small);
squares.push_back(large);

{
  // When different_scope goes out of scope, it removes itself from the list.
  Square different_scope = Square(5);
  squares.push_back(&different_scope);
}

for (const auto& square : squares) {
  PW_LOG_INFO("Found a square with an area of %lu", square.Area());
}

// Like std::forward_list, an iterator is invalidated when the item it refers
// to is removed. It is *NOT* safe to remove items from a list while iterating
// over it in a range-based for loop.
for (const auto& square_bad_example : squares) {
  if (square_bad_example.verticies() != 4) {
    // BAD EXAMPLE of how to remove matching items from a singly linked list.
    squares.remove(square_bad_example);  // NEVER DO THIS! THIS IS A BUG!
  }
}

// To remove items while iterating, use an iterator to the previous item.
auto previous = squares.before_begin();
auto current = squares.begin();

while (current != squares.end()) {
  if (current->verticies() != 4) {
    current = squares.erase_after(previous);
  } else {
    previous = current;
    ++current;
  }
}

Performance Considerations#

Items only include pointers to the next item. To reach previous items, the list maintains a cycle of items so that the first item can be reached from the last. This structure means certain operations have linear complexity in terms of the number of items in the list, i.e. they are “O(n)”:

  • Adding to the end of a list with pw::IntrusiveList<T>::push_back(T&).

  • Accessing the last item in a list with pw::IntrusiveList<T>::back().

  • Destroying an item with pw::IntrusiveList<T>::Item::~Item().

  • Moving an item with either pw::IntrusiveList<T>::Item::Item(Item&&) or pw::IntrusiveList<T>::Item::operator=(Item&&).

  • Removing an item from a list using pw::IntrusiveList<T>::remove(const T&).

  • Getting the list size using pw::IntrusiveList<T>::size().

When using a pw::IntrusiveList<T> in a performance critical section or with many items, authors should prefer to avoid these methods. For example, it may be preferrable to create items that together with their storage outlive the list.

Notably, pw::IntrusiveList<T>::end() is constant complexity (i.e. “O(1)”). As a result iterating over a list does not incur an additional penalty.

pw::containers::FlatMap#

FlatMap provides a simple, fixed-size associative array with O(log n) lookup by key.

pw::containers::FlatMap contains the same methods and features for looking up data as std::map. However, modification of the underlying data is limited to the mapped values, via .at() (key must exist) and mapped_iterator objects returned by .mapped_begin() and .mapped_end(). mapped_iterator objects are bidirectional iterators that can be dereferenced to access and mutate the mapped value objects.

The underlying array in pw::containers::FlatMap does not need to be sorted. During construction, pw::containers::FlatMap will perform a constexpr insertion sort.

pw::containers::FilteredView#

template<typename Container, typename Filter>
class FilteredView#

pw::containers::FilteredView provides a view of a container with only elements that match the specified filter. This class is similar to C++20’s std::ranges::filter_view.

FilteredView works with any container with an incrementable iterator. The back() function currently requires a bidirectional iterator.

To create a FilteredView, pass a container and a filter predicate, which may be any callable type including a function pointer, lambda, or pw::Function.

std::array<int, 99> kNumbers = {3, 1, 4, 1, ...};

for (int n : FilteredView(kNumbers, [](int v) { return v % 2 == 0; })) {
  PW_LOG_INFO("This number is even: %d", n);
}

pw::containers::WrappedIterator#

pw::containers::WrappedIterator is a class that makes it easy to wrap an existing iterator type. It reduces boilerplate by providing operator++, operator--, operator==, operator!=, and the standard iterator aliases (difference_type, value_type, etc.). It does not provide the dereference operator; that must be supplied by a derived class.

To use it, create a class that derives from WrappedIterator and define operator*() and operator->() as appropriate. The new iterator might apply a transformation to or access a member of the values provided by the original iterator. The following example defines an iterator that multiplies the values in an array by 2.

// Divides values in a std::array by two.
class DoubleIterator
    : public pw::containers::WrappedIterator<DoubleIterator, const int*, int> {
 public:
  constexpr DoubleIterator(const int* it) : WrappedIterator(it) {}

  int operator*() const { return value() * 2; }

  // Don't define operator-> since this iterator returns by value.
};

constexpr std::array<int, 6> kArray{0, 1, 2, 3, 4, 5};

void SomeFunction {
  for (DoubleIterator it(kArray.begin()); it != DoubleIterator(kArray.end()); ++it) {
    // The iterator yields 0, 2, 4, 6, 8, 10 instead of the original values.
  }
};

WrappedIterator may be used in concert with FilteredView to create a view that iterates over a matching values in a container and applies a transformation to the values. For example, it could be used with FilteredView to filter a list of packets and yield only one field from the packet.

The combination of FilteredView and WrappedIterator provides some basic functional programming features similar to (though much more cumbersome than) generator expressions (or filter/map) in Python or streams in Java 8. WrappedIterator and FilteredView require no memory allocation, which is helpful when memory is too constrained to process the items into a new container.

pw::containers::to_array#

pw::containers::to_array is a C++14-compatible implementation of C++20’s std::to_array. In C++20, it is an alias for std::to_array. It converts a C array to a std::array.

pw_containers/algorithm.h#

Pigweed provides a set of Container-based versions of algorithmic functions within the C++ standard library, based on a subset of absl/algorithm/container.h.

bool pw::containers::AllOf()#

Container-based version of the <algorithm> std::all_of() function to test if all elements within a container satisfy a condition.

bool pw::containers::AnyOf()#

Container-based version of the <algorithm> std::any_of() function to test if any element in a container fulfills a condition.

bool pw::containers::NoneOf()#

Container-based version of the <algorithm> std::none_of() function to test if no elements in a container fulfill a condition.

pw::containers::ForEach()#

Container-based version of the <algorithm> std::for_each() function to apply a function to a container’s elements.

pw::containers::Find()#

Container-based version of the <algorithm> std::find() function to find the first element containing the passed value within a container value.

pw::containers::FindIf()#

Container-based version of the <algorithm> std::find_if() function to find the first element in a container matching the given condition.

pw::containers::FindIfNot()#

Container-based version of the <algorithm> std::find_if_not() function to find the first element in a container not matching the given condition.

pw::containers::FindEnd()#

Container-based version of the <algorithm> std::find_end() function to find the last subsequence within a container.

pw::containers::FindFirstOf()#

Container-based version of the <algorithm> std::find_first_of() function to find the first element within the container that is also within the options container.

pw::containers::AdjacentFind()#

Container-based version of the <algorithm> std::adjacent_find() function to find equal adjacent elements within a container.

pw::containers::Count()#

Container-based version of the <algorithm> std::count() function to count values that match within a container.

pw::containers::CountIf()#

Container-based version of the <algorithm> std::count_if() function to count values matching a condition within a container.

pw::containers::Mismatch()#

Container-based version of the <algorithm> std::mismatch() function to return the first element where two ordered containers differ. Applies == to the first N elements of c1 and c2, where N = min(size(c1), size(c2)). the function’s test condition. Applies pred to the first N elements of c1 and c2, where N = min(size(c1), size(c2)).

bool pw::containers::Equal()#

Container-based version of the <algorithm> std::equal() function to test whether two containers are equal.

Note

The semantics of Equal() are slightly different than those of std::equal(): while the latter iterates over the second container only up to the size of the first container, Equal() also checks whether the container sizes are equal. This better matches expectations about Equal() based on its signature.

bool pw::containers::IsPermutation()#

Container-based version of the <algorithm> std::is_permutation() function to test whether a container is a permutation of another.

pw::containers::Search()#

Container-based version of the <algorithm> std::search() function to search a container for a subsequence.

pw::containers::SearchN()#

Container-based version of the <algorithm> std::search_n() function to search a container for the first sequence of N elements.

Compatibility#

  • C++17

Zephyr#

To enable pw_containers for Zephyr add CONFIG_PIGWEED_CONTAINERS=y to the project’s configuration.