Pigweed
 
Loading...
Searching...
No Matches
pw::multibuf::MultiBufChunks Class Reference

A Chunk-oriented view of a MultiBuf. More...

#include <multibuf.h>

Inheritance diagram for pw::multibuf::MultiBufChunks:
pw::multibuf::MultiBuf

Classes

class  const_iterator
 A const std::forward_iterator over the Chunks of a MultiBuf. More...
 
class  iterator
 A std::forward_iterator over the Chunks of a MultiBuf. More...
 

Public Types

using element_type = Chunk
 
using value_type = Chunk
 
using pointer = Chunk *
 
using reference = Chunk &
 
using const_pointer = const Chunk *
 
using difference_type = std::ptrdiff_t
 
using const_reference = const Chunk &
 
using size_type = std::size_t
 

Public Member Functions

 MultiBufChunks (const MultiBufChunks &)=delete
 
MultiBufChunksoperator= (const MultiBufChunks &)=delete
 
constexpr Chunkfront ()
 
constexpr const Chunkfront () const
 
Chunkback ()
 
const Chunkback () const
 
constexpr iterator begin ()
 
constexpr const_iterator begin () const
 
constexpr const_iterator cbegin () const
 
constexpr iterator end ()
 
constexpr const_iterator end () const
 
constexpr const_iterator cend () const
 
size_t size () const
 Returns the number of Chunks in this MultiBuf, including empty chunks.
 
size_t size_bytes () const
 Returns the total number of bytes in all Chunks.
 
bool empty () const
 Returns whether the MultiBuf contains any chunks (size() == 0).
 
void push_front (OwnedChunk &&chunk)
 
void push_back (OwnedChunk &&chunk)
 
OwnedChunk take_front ()
 
iterator insert (iterator position, OwnedChunk &&chunk)
 
std::tuple< iterator, OwnedChunktake (iterator position)
 

Protected Member Functions

constexpr MultiBufChunks (Chunk *first_chunk)
 
 ~MultiBufChunks ()
 This destructor will acquire a mutex and is not IRQ safe.
 
 PW_MODIFY_DIAGNOSTICS_PUSH ()
 
 PW_MODIFY_DIAGNOSTIC_GCC (ignored, "-Wmaybe-uninitialized")
 
constexpr MultiBufChunks (MultiBufChunks &&other) noexcept
 
 PW_MODIFY_DIAGNOSTICS_POP ()
 
MultiBufChunksoperator= (MultiBufChunks &&other) noexcept
 
void Release () noexcept
 
void PushSuffix (MultiBufChunks &&tail)
 
ChunkPrevious (Chunk *chunk) const
 

Detailed Description

A Chunk-oriented view of a MultiBuf.

Member Function Documentation

◆ back()

Chunk & pw::multibuf::MultiBufChunks::back ( )
inline

Returns a reference to the final chunk.

The behavior of this method is undefined when size() == 0.

NOTE: this method is O(size()).

◆ front()

constexpr Chunk & pw::multibuf::MultiBufChunks::front ( )
inlineconstexpr

Returns a reference to the first chunk.

The behavior of this method is undefined when size() == 0.

◆ insert()

iterator pw::multibuf::MultiBufChunks::insert ( iterator  position,
OwnedChunk &&  chunk 
)

Inserts chunk into the specified position in the MultiBuf. The Chunk at position will be after the new chunk.

This operation does not move any data and is O(Chunks().size()).

Returns an iterator pointing to the newly-inserted Chunk.

◆ Previous()

Chunk * pw::multibuf::MultiBufChunks::Previous ( Chunk chunk) const
protected

Returns the Chunk preceding chunk in this MultiBuf.

Requires that this MultiBuf is not empty, and that chunk is either in MultiBuf or is nullptr, in which case the last Chunk in MultiBuf will be returned.

This operation is O(Chunks().size()).

◆ push_back()

void pw::multibuf::MultiBufChunks::push_back ( OwnedChunk &&  chunk)

Pushes Chunk onto the end of the MultiBuf.

This operation does not move any data and is O(Chunks().size()).

◆ push_front()

void pw::multibuf::MultiBufChunks::push_front ( OwnedChunk &&  chunk)

Pushes Chunk onto the front of the MultiBuf.

This operation does not move any data and is O(1).

◆ take()

std::tuple< iterator, OwnedChunk > pw::multibuf::MultiBufChunks::take ( iterator  position)

Removes and returns Chunk from the specified position.

This operation does not move any data and is O(Chunks().size()).

Returns an iterator pointing to the Chunk after the removed Chunk, or Chunks().end() if this was the last Chunk in the MultiBuf.

◆ take_front()

OwnedChunk pw::multibuf::MultiBufChunks::take_front ( )

Removes the first Chunk.

This operation does not move any data and is O(1).


The documentation for this class was generated from the following file: