iffl
1.3.4
Implements Intrusive Flat Forward List container
|
Non owning container for flat forward list. More...
#include <iffl_list.h>
Public Types | |
using | value_type = T |
Element value type. | |
using | pointer = T * |
Pointer to element type. | |
using | const_pointer = T const * |
Pointer to const element type. | |
using | reference = T & |
Reference to the element type. | |
using | const_reference = T const & |
Reference to the const element type. | |
using | size_type = std::size_t |
Size type. | |
using | difference_type = std::ptrdiff_t |
Element pointers difference type. | |
using | traits = TT |
Element traits type. | |
using | traits_traits = flat_forward_list_traits_traits< T, TT > |
Element traits-traits type. | |
using | range_t = typename traits_traits::range_t |
Vocabulary type used to describe buffer used by the element and how much of this buffer is used by the data. Type also includes information about required alignment. | |
using | size_with_padding_t = typename traits_traits::size_with_padding_t |
Vocabulary type used to describe size with padding. | |
using | offset_with_aligment_t = typename traits_traits::offset_with_aligment_t |
Vocabulary type used to describe size with alignment. | |
using | sizes_t = flat_forward_list_sizes< traits_traits::alignment > |
Vocabulary type that contains information about buffer size, and last element range. | |
using | buffer_value_type = std::conditional_t< std::is_const_v< T >, char const, char > |
Depending if T is const we will use const or non-const buffer pointer. More... | |
using | const_buffer_value_type = buffer_value_type const |
When we do not intend to modify buffer we can treat it as a bag of const characters. | |
using | buffer_pointer = buffer_value_type * |
Type used as a buffer pointer. | |
using | const_buffer_pointer = const_buffer_value_type * |
Type used as a pointer not the const buffer. | |
using | iterator = flat_forward_list_iterator< T, TT > |
Type of iterator. | |
using | const_iterator = flat_forward_list_const_iterator< T, TT > |
Type of const iterator. | |
using | buffer_type = buffer_t< buffer_value_type > |
Pointers that describe buffer. More... | |
Public Member Functions | |
flat_forward_list_ref () noexcept | |
Default constructor. | |
template<typename V , typename VV , typename = std::enable_if<std::is_assignable_v<T*, V*>>> | |
flat_forward_list_ref (flat_forward_list_ref< V, VV > const &other) noexcept | |
Assignment operator to view from a ref. More... | |
flat_forward_list_ref (buffer_type const &other_buff) noexcept | |
Constructor that initializes view to point to the buffer. More... | |
flat_forward_list_ref (buffer_pointer buffer_begin, buffer_pointer last_element, buffer_pointer buffer_end) noexcept | |
Constructor that copies list from a buffer. More... | |
template<typename V , typename VV , typename = std::enable_if<std::is_assignable_v<T*, V*>>> | |
flat_forward_list_ref (flat_forward_list_iterator< V, VV > const &begin, flat_forward_list_iterator< V, VV > const &last) noexcept | |
Constructor that creates a view over a buffer described by a pair of iterators. More... | |
flat_forward_list_ref (buffer_pointer *buffer, size_t buffer_size) noexcept | |
Constructor that checks if buffer contains a valid list and if it does then copies that list. More... | |
template<typename V , typename VV , typename A , typename UNUSED = std::enable_if<std::is_assignable_v<T*, V*>>> | |
flat_forward_list_ref (flat_forward_list< V, VV, A > const &c) noexcept | |
Constructs view from container. More... | |
template<typename V , typename VV , typename = std::enable_if<std::is_assignable_v<T*, V*>>> | |
flat_forward_list_ref & | operator= (flat_forward_list_ref< V, VV > const &other) |
Copy assignment operator. More... | |
flat_forward_list_ref & | operator= (buffer_view const &other_buffer) |
Copy assignment operator. More... | |
template<typename V , typename VV , typename A , typename UNUSED = std::enable_if<std::is_assignable_v<T*, V*>>> | |
flat_forward_list_ref & | operator= (flat_forward_list< V, VV, A > const &c) noexcept |
Constructs view from container. More... | |
~flat_forward_list_ref () noexcept | |
Destructor. More... | |
void | assign (buffer_type const &other_buff) noexcept |
Assigns view to point to the described buffer. More... | |
void | assign (buffer_pointer buffer_begin, buffer_pointer last_element, buffer_pointer buffer_end) noexcept |
Assigns view to point to the described buffer. More... | |
template<typename V , typename VV , typename = std::enable_if<std::is_assignable_v<T*, V*>>> | |
void | assign (flat_forward_list_iterator< V, VV > const &begin, flat_forward_list_iterator< V, VV > const &last) noexcept |
Assigns view to point to the described buffer. More... | |
void | assign (buffer_pointer *buffer, size_t buffer_size) noexcept |
Assigns view to point to the described buffer. More... | |
void | swap (flat_forward_list_ref &other) noexcept |
Swaps content of this container and the other container. More... | |
T & | front () |
T const & | front () const |
T & | back () |
T const & | back () const |
iterator | begin () noexcept |
const_iterator | begin () const noexcept |
iterator | last () noexcept |
const_iterator | last () const noexcept |
iterator | end () noexcept |
const_iterator | end () const noexcept |
const_iterator | cbegin () const noexcept |
const_iterator | clast () const noexcept |
const_iterator | cend () const noexcept |
char * | data () noexcept |
char const * | data () const noexcept |
bool | revalidate_data () noexcept |
Validates that buffer contains a valid list. More... | |
size_type | required_size (const_iterator const &it) const noexcept |
Returns capacity used by the element's data. More... | |
size_type | used_size (const_iterator const &it) const noexcept |
range_t | range (const_iterator const &it) const noexcept |
Information about the buffer occupied by an element. More... | |
range_t | closed_range (const_iterator const &begin, const_iterator const &last) const noexcept |
Information about the buffer occupied by elements in the range [begin, last]. More... | |
range_t | half_open_range (const_iterator const &begin, const_iterator const &end) const noexcept |
Information about the buffer occupied by elements in the range [begin, end). More... | |
bool | contains (const_iterator const &it, size_type position) const noexcept |
Tells if given offset in the buffer falls into a buffer used by the element. More... | |
const_iterator | find_element_before (size_type position) const noexcept |
Searches for an element before the element that contains given position. More... | |
const_iterator | find_element_at (size_type position) const noexcept |
Searches for an element that contains given position. More... | |
const_iterator | find_element_after (size_type position) const noexcept |
Searches for an element after the element that contains given position. More... | |
size_type | size () const noexcept |
Number of elements in the container. More... | |
bool | empty () const noexcept |
Tells if container contains no elements. More... | |
operator bool () const | |
size_type | used_capacity () const noexcept |
size_type | total_capacity () const noexcept |
size_type | remaining_capacity () const noexcept |
template<typename V , typename VV , typename A , typename UNUSED > | |
flat_forward_list_ref< T, TT > & | operator= (flat_forward_list< V, VV, A > const &c) noexcept |
Constructs ref or view from container. More... | |
Static Public Attributes | |
static bool const | is_ref { !std::is_const_v<T> } |
True if this is a ref and false if this is a view. | |
static size_type const | npos = iffl::npos |
Constant that represents and invalid or non-existent position. | |
Non owning container for flat forward list.
Forward declaration of intrusive flat forward list reference.
T | - element type |
TT | - element type traits Provides helpers accessing elements of the buffer without taking ownership of the buffer. |
iffl::flat_forward_list_ref< T, TT >::buffer_type |
Pointers that describe buffer.
Depending if T is const buffer uses char * or char const *
iffl::flat_forward_list_ref< T, TT >::buffer_value_type |
Depending if T is const we will use const or non-const buffer pointer.
Since we have variable size elements, and we cannot express it in the C++ type system we treat buffer with elements as a bag of chars and cast to the element type when necessary.
|
inlinenoexcept |
Assignment operator to view from a ref.
V | - For SFINAE we need to make this method a template Type const iterator is pointing to. |
VV | - Type traits. |
Use SFINAE to enable it only on const instantiation to support assignment from a non-const instantiation of template
|
inlineexplicitnoexcept |
Constructor that initializes view to point to the buffer.
other_buff | - pointer to the start of the buffer that contains list. |
This constructor does not validate if this is a valid flat forward list. It assumes that caller validated buffer before using this constructor.
|
inlinenoexcept |
Constructor that copies list from a buffer.
buffer_begin | - pointer to the start of the buffer that contains list. |
buffer_end | - pointer to the address right after last byte in the buffer. |
last_element | - pointers to the last element of the list in the buffer. If buffer does not contain any elements then this parameter must be nullptr. |
This constructor does not validate if this is a valid flat forward list. It assumes that caller validated buffer before using this constructor.
|
inlinenoexcept |
Constructor that creates a view over a buffer described by a pair of iterators.
V | - For SFINAE we need to make this method a template Type const iterator is pointing to. |
VV | - Type traits. |
begin | - iterator for the buffer begin. |
last | - last element that should be included in the view |
This constructor does not validate if this is a valid flat forward list. It assumes that caller validated buffer before using this constructor.
|
inlinenoexcept |
Constructor that checks if buffer contains a valid list and if it does then copies that list.
buffer | - pointer to the start of the buffer that might contains list. |
buffer_size | - buffer size. |
This constructor searches for the last valid element in the buffer, and is buffer is valid then it copies elements to the new buffer.
|
explicitnoexcept |
Constructs view from container.
Constructs ref or view from container.
V | - For SFINAE we need to make this method a template Type const iterator is pointing to. |
VV | - Type traits. |
A | - allocator type |
c | - container we are constructing view from |
T | - element type |
TT | - element type traits |
A | - allocator type |
|
inlinenoexcept |
Destructor.
Deallocates buffer owned by container.
|
inlinenoexcept |
Assigns view to point to the described buffer.
other_buff | - pointer to the start of the buffer that contains list. |
This method does not validate if this is a valid flat forward list. It assumes that caller validated buffer before using this constructor.
|
inlinenoexcept |
Assigns view to point to the described buffer.
buffer_begin | - pointer to the start of the buffer that contains list. |
last_element | - pointer to the last element of the list. |
buffer_end | - pointer to the end of the buffer. |
This method does not validate if this is a valid flat forward list. It assumes that caller validated buffer before using this constructor.
|
inlinenoexcept |
Assigns view to point to the described buffer.
V | - For SFINAE we need to make this method a template Type const iterator is pointing to. |
VV | - Type traits. |
begin | - iterator for the buffer begin. |
last | - last element that should be included in the view |
|
inlinenoexcept |
Assigns view to point to the described buffer.
buffer | - pointer to the begin of a buffer. |
buffer_size | - size of the buffer. |
|
inline |
Calling this method on a empty container will trigger fail-fast
|
inline |
Calling this method on a empty container will trigger fail-fast
|
inlinenoexcept |
Calling on an empty container returns end iterator
|
inlinenoexcept |
Calling on an empty container returns const end iterator
|
inlinenoexcept |
Calling on an empty container returns const end iterator
|
inlinenoexcept |
For types that support get_next_offset offset or when container is empty, the end iterator is const_iterator{}. For types that do not support get_next_offset an end iterator is pointing pass the last element of container
|
inlinenoexcept |
Calling on an empty container returns end iterator
|
inlinenoexcept |
Information about the buffer occupied by elements in the range [begin, last].
begin | - iterator pointing to the first element. |
last | - iterator pointing to the last element in the range. |
All offsets values are relative to the buffer owned by the container.
|
inlinenoexcept |
Tells if given offset in the buffer falls into a buffer used by the element.
it | - iterator pointing to an element |
position | - offset in the container's buffer. |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Tells if container contains no elements.
Both container with no buffer as well as container that has buffer that does not contain any valid elements will return true.
|
inlinenoexcept |
An end iterator is pointing pass the last element of container. View might be pointing in a middle of a flat forward list so our last element might be not a last element of list. It is arbitrary what we are using as a pointer to the last element, as long as we are using it consistently. This implementation uses
|
inlinenoexcept |
An end iterator is pointing pass the last element of container View might be pointing in a middle of a flat forward list so our last element might be not a last element of list. It is arbitrary what we are using as a pointer to the last element, as long as we are using it consistently. This implementation uses
|
inlinenoexcept |
Searches for an element after the element that contains given position.
position | - offset in the container's buffer |
Cost of this algorithm is O(number of elements in container) because we have to performs linear search for an element from the start of container's buffer.
|
inlinenoexcept |
Searches for an element that contains given position.
position | - offset in the container's buffer |
Cost of this algorithm is O(number of elements in container) because we have to performs linear search for an element from the start of container's buffer.
|
inlinenoexcept |
Searches for an element before the element that contains given position.
position | - offset in the container's buffer |
Cost of this algorithm is O(number of elements in container) because we have to performs linear search for an element from the start of container's buffer.
|
inline |
Calling this method on a empty container will trigger fail-fast
|
inline |
Calling this method on a empty container will trigger fail-fast
|
inlinenoexcept |
Information about the buffer occupied by elements in the range [begin, end).
begin | - iterator pointing to the first element. |
end | - iterator pointing to the past last element in the range. |
All offsets values are relative to the buffer owned by the container. Algorithm has complexity O(number of elements in collection) because to find element before end we have to scan buffer from beginning.
|
inlinenoexcept |
Calling on an empty container returns end iterator
|
inlinenoexcept |
Calling on an empty container returns end iterator
|
inlineexplicit |
|
inline |
Copy assignment operator.
other | - linked list we are moving from |
|
inline |
Copy assignment operator.
other_buffer | - linked list we are copying from |
|
noexcept |
Constructs view from container.
V | - For SFINAE we need to make this method a template Type const iterator is pointing to. |
VV | - Type traits. |
A | - allocator type |
c | - container we are constructing view from |
|
noexcept |
Constructs ref or view from container.
T | - element type |
TT | - element type traits |
A | - allocator type |
|
inlinenoexcept |
Information about the buffer occupied by an element.
it | - iterator pointing to an element. |
All offsets values are relative to the buffer owned by the container.
|
inlinenoexcept |
|
inlinenoexcept |
Returns capacity used by the element's data.
it | - iterator pointing to the element we are returning size for. |
|
inlinenoexcept |
Validates that buffer contains a valid list.
You must call this method after passing pointer to container's buffer to a function that might change buffer content. If valid list of found then buff().last will be pointing to the element that was found. If no valid list was found then buff().last will be nullptr.
|
inlinenoexcept |
Number of elements in the container.
Cost of this algorithm is O(number of elements in container). Container does not actively cache/updates element count so we need to scan list to find number of elements.
|
inlinenoexcept |
Swaps content of this container and the other container.
other | - reference to the other container |
might | throw std::bad_alloc if allocator swap throws or if allocators do not support swap, and we need to make a copy of elements, which involves allocation. |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
it | - iterator pointing to the element we are returning size for. |