iffl  1.3.4
Implements Intrusive Flat Forward List container
Public Member Functions | Public Attributes | List of all members
iffl::range Class Reference

Vocabulary type that describes a sub-buffer in a larger buffer, and portion of that sub-buffer actually used by the data. More...

#include <iffl_common.h>

Inheritance diagram for iffl::range:
iffl::range_with_alighment< ALIGNMENT_V >

Public Member Functions

constexpr size_t begin () const
 Offset of the element buffer begin in a larger buffer. More...
 
constexpr void verify () const noexcept
 Fail fast if range invariants are broken.
 
constexpr size_t data_size () const noexcept
 Data size. More...
 
constexpr size_t buffer_size () const noexcept
 Buffer size. More...
 
constexpr size_t unused_capacity () const noexcept
 Size of unused buffer. More...
 
void fill_unused_capacity_data_ptr (char *data_ptr, int fill_byte) const noexcept
 Fills unused part of buffer with fill_byte. More...
 
void zero_unused_capacity_data_ptr (char *data_ptr) const noexcept
 Zeros unused part of buffer. More...
 
void fill_unused_capacity_container_ptr (char *container_ptr, int fill_byte) const noexcept
 Fills unused part of buffer with fill_byte. More...
 
void zero_unused_capacity_container_ptr (char *container_ptr) const noexcept
 Zeros unused part of buffer. More...
 
constexpr bool buffer_contains (size_t position) const noexcept
 Tells if position falls into the buffer. More...
 
constexpr bool data_contains (size_t position) const noexcept
 Tells if position falls into the data buffer. More...
 

Public Attributes

size_t buffer_begin { 0 }
 Starting offset of element in a buffer Element always starts at the beginning of the buffer.
 
size_t data_end { 0 }
 Offset in the buffer where data end.
 
size_t buffer_end { 0 }
 Offset of the end of the buffer Next element of the flat list starts at this offset.
 

Detailed Description

Vocabulary type that describes a sub-buffer in a larger buffer, and portion of that sub-buffer actually used by the data.

Following picture explains that concept

| | |
V V V
---------------------------------------------------------------
| .... | <element data> | <unused space> | [next element] ... |
---------------------------------------------------------------

unused space between data_end and buffer_end is either reserved space for the element in the buffer and/or padding to keep next element aligned. This vocabulary type is a convenient building block for flat list. When we move elements in the buffer it is more convenient to operate on relative offsets in the buffer.

Member Function Documentation

◆ begin()

constexpr size_t iffl::range::begin ( ) const
inline

Offset of the element buffer begin in a larger buffer.

Returns
current value of buffer_begin

◆ buffer_contains()

constexpr bool iffl::range::buffer_contains ( size_t  position) const
inlinenoexcept

Tells if position falls into the buffer.

Parameters
position- position offset in the parent buffer

◆ buffer_size()

constexpr size_t iffl::range::buffer_size ( ) const
inlinenoexcept

Buffer size.

Returns
Returns size of buffer in bytes

◆ data_contains()

constexpr bool iffl::range::data_contains ( size_t  position) const
inlinenoexcept

Tells if position falls into the data buffer.

Parameters
position- position offset in the parent buffer

◆ data_size()

constexpr size_t iffl::range::data_size ( ) const
inlinenoexcept

Data size.

Returns
Returns number of bytes used by the element data

◆ fill_unused_capacity_container_ptr()

void iffl::range::fill_unused_capacity_container_ptr ( char *  container_ptr,
int  fill_byte 
) const
inlinenoexcept

Fills unused part of buffer with fill_byte.

Parameters
container_ptr- a pointer to the buffer start
fill_byte- a value to fill bytes with

◆ fill_unused_capacity_data_ptr()

void iffl::range::fill_unused_capacity_data_ptr ( char *  data_ptr,
int  fill_byte 
) const
inlinenoexcept

Fills unused part of buffer with fill_byte.

Parameters
data_ptr- a pointer to the element start
fill_byte- a value to fill bytes with

◆ unused_capacity()

constexpr size_t iffl::range::unused_capacity ( ) const
inlinenoexcept

Size of unused buffer.

Returns
Returns size of buffer not used by the data

◆ zero_unused_capacity_container_ptr()

void iffl::range::zero_unused_capacity_container_ptr ( char *  container_ptr) const
inlinenoexcept

Zeros unused part of buffer.

Parameters
container_ptr- a pointer to the buffer start

◆ zero_unused_capacity_data_ptr()

void iffl::range::zero_unused_capacity_data_ptr ( char *  data_ptr) const
inlinenoexcept

Zeros unused part of buffer.

Parameters
data_ptr- a pointer to the element start

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