pabigot
0.1.1
C++ support classes
|
Go to the documentation of this file. 10 #ifndef PABIGOT_CONTAINER_HPP 11 #define PABIGOT_CONTAINER_HPP 34 template <
typename T = u
int8_t>
69 rr_adaptor () =
delete;
70 rr_adaptor (
const rr_adaptor&) =
delete;
71 rr_adaptor& operator= (
const rr_adaptor&) =
delete;
72 rr_adaptor (rr_adaptor&&) =
delete;
73 rr_adaptor& operator= (rr_adaptor&&) =
delete;
83 bool full () const noexcept
126 }
else if (tail_ == head_) {
130 auto nh = next_index_(head_);
146 tail_ = next_index_(tail_);
147 if (head_ == tail_) {
238 template <
typename T,
288 from.front_ = from.back_ =
nullptr;
291 forward_chain& operator= (forward_chain&& from) noexcept
293 front_ = from.front_;
295 from.front_ = from.back_ =
nullptr;
321 current{chain.front_},
322 next{current ? chain.ref_next(*current) :
nullptr}
356 next = chain.ref_next(*current);
409 return ref_next(elt);
426 ref_next(value) = front_;
435 auto&
next = ref_next(*rv);
452 ref_next(value) = ref_next(pos);
453 ref_next(pos) = &value;
476 ref_next(value) = np;
480 npp = &ref_next(*np);
499 || (!pred(*front_))) {
503 auto npp = &ref_next(*prev);
504 while ((*npp) && pred(**npp)) {
506 npp = &ref_next(*prev);
514 return {
front, prev};
525 ref_next(value) =
nullptr;
526 ref_next(*back_) = &value;
544 auto&
next = ref_next(value);
547 if (&value == back_) {
553 lpp = &ref_next(*lp);
563 auto&
next = ref_next(*p);
567 front_ = back_ =
nullptr;
582 return REF_NEXT{}(elt);
void link_front(value_type &value) noexcept
Add the value to the front of the sequence.
Definition: container.hpp:421
static constexpr uintptr_t UNLINKED_PTR
Integral value of an invalid pointer used to denote unlinked objects.
Definition: container.hpp:256
uint16_t size_type
Type alias for representing the size of the buffer.
Definition: container.hpp:48
static constexpr size_type EMPTY_HEAD
Marker value stored in #head_ to indicate that the buffer is empty.
Definition: container.hpp:54
bool push(value_type v) noexcept
Push a new value at the front of the buffer.
Definition: container.hpp:120
pointer_type unlink_front() noexcept
Remove and return a pointer to the first value of the sequence.
Definition: container.hpp:431
void link_after(value_type &pos, value_type &value) noexcept
Add the value immediately after an value already in the sequence.
Definition: container.hpp:449
General-use material that applies to all of pabigot.
void link_back(value_type &value) noexcept
Add the value to the end of the sequence.
Definition: container.hpp:520
bool operator==(const end_iterator_type &)
Return true iff this iterator is past the end of its chain.
Definition: container.hpp:338
bool empty() const noexcept
Indicate whether the sequence is empty.
Definition: container.hpp:390
value_type pop() noexcept
Pop a value from the back of the buffer.
Definition: container.hpp:140
size_type size() const noexcept
The number of values currently stored in the buffer.
Definition: container.hpp:98
size_type max_size() const noexcept
The maximum number of values that can be stored in the buffer.
Definition: container.hpp:92
bool is_unlinked(pointer_type ptr) const noexcept
Test whether a pointer is unlinked.
Definition: container.hpp:265
pointer_type back() const noexcept
Return a pointer to the last value in the sequence.
Definition: container.hpp:413
pointer_type unlink(value_type &value) noexcept
Remove an value from the sequence at any position.
Definition: container.hpp:536
std::make_signed< size_type >::type ssize_type
Type alias for signed size values.
Definition: container.hpp:51
constexpr rr_adaptor(value_type *data, size_type count)
Create an adaptor for round-robin access to a fixed buffer.
Definition: container.hpp:63
bool operator!=(const end_iterator_type &rhs)
Minimum operator required for range-for support.
Definition: container.hpp:346
Sentinal type used as end-of-chain iterator value.
Definition: container.hpp:300
void clear() noexcept
Restore the buffer to an empty state.
Definition: container.hpp:154
value_type * pointer_type
The type for a pointer to value_type.
Definition: container.hpp:250
void link_before(value_type &value, predicate_type pred) noexcept
Add the value immediately before the first value in the sequence for which pred is true.
Definition: container.hpp:469
Iterator type designed to support range-for.
Definition: container.hpp:315
T value_type
Type alias for the elements of the buffer.
Definition: container.hpp:39
A basic round-robin (circular) homogeneous buffer with externally-allocated capacity.
Definition: container.hpp:35
Root for all pabigot namespaces.
Definition: gap.hpp:15
pointer_type next(value_type &elt) const noexcept
Return a pointer to the next value in the sequence.
Definition: container.hpp:407
chain_iterator_type & operator++()
Increment to reference the cached successor of the current.
Definition: container.hpp:352
T value_type
The type of object linked by this chain.
Definition: container.hpp:247
chain_iterator_type begin() const noexcept
Get an iterator that starts at the beginning of the chain.
Definition: container.hpp:377
bool is_unlinked(value_type &value) const noexcept
Test whether a value is unlinked.
Definition: container.hpp:271
chain_type split_through(predicate_type pred) noexcept
Strip off a chain of all leading elements that satisfy a predicate.
Definition: container.hpp:496
bool empty() const noexcept
true iff the buffer has no data in it.
Definition: container.hpp:76
pointer_type front() const noexcept
Return a pointer to the first value in the sequence.
Definition: container.hpp:396
void clear() noexcept
Remove all values from the sequence.
Definition: container.hpp:559
std::function< bool(const value_type &)> predicate_type
The type for a function that tests a value_type for a condition.
Definition: container.hpp:253
static pointer_type unlinked_ptr() noexcept
Test whether a pointer is unlinked.
Definition: container.hpp:259
end_iterator_type end() const noexcept
Get a value end for which iter != end will return false only when iter is a chain_iterator_type that ...
Definition: container.hpp:384
Container used to link objects into a sequence.
Definition: container.hpp:240
value_type & operator*() noexcept
Get a reference to the value in the chain.
Definition: container.hpp:370
bool full() const noexcept
true if the buffer cannot receive more data without discarding an element.
Definition: container.hpp:83