libhatchet
Loading...
Searching...
No Matches
hxdeque< T, capacity_ > Class Template Reference

#include <hxdeque.hpp>

Classes

class  const_iterator
class  iterator

Public Member Functions

 hxdeque (hxsize_t dynamic_capacity_=0)
 ~hxdeque (void)
const T & operator[] (hxsize_t index_) const
T & operator[] (hxsize_t index_)
bool operator== (const hxdeque &x_) const
bool operator< (const hxdeque &x_) const
const_iterator begin (void) const
iterator begin (void)
template<hxrange_concept_ range_t_>
void add_range (range_t_ &range_) noexcept
template<hxrange_concept_ range_t_, hxenable_if_t<!hxis_lvalue_reference< range_t_ >(), int > = 0>
void add_range (range_t_ &&range_) noexcept
T & back (void)
const T & back (void) const
hxsize_t capacity (void) const
const_iterator cbegin (void) const
const_iterator cend (void) const
void clear (void) noexcept
template<typename... args_t_>
void emplace_back (args_t_ &&... args_) noexcept
template<typename... args_t_>
void emplace_front (args_t_ &&... args_) noexcept
bool empty (void) const
const_iterator end (void) const
iterator end (void)
T & front (void)
const T & front (void) const
bool full (void) const
hxsize_t max_size (void) const
void pop_back (void) noexcept
void pop_front (void) noexcept
template<typename... args_t_>
void push_back (args_t_ &&... args_) noexcept
template<typename... args_t_>
void push_front (args_t_ &&... args_) noexcept
void reserve (hxsize_t dynamic_capacity_)
hxsize_t size (void) const

Detailed Description

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
class hxdeque< T, capacity_ >

hxdeque - A fixed-capacity deque backed by a power-of-two ring buffer.

All operations are O(1). The effective capacity must be a power of two and positive once storage is allocated. This is designed to do one thing very well and that is all.

Constructor & Destructor Documentation

◆ hxdeque()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
hxdeque< T, capacity_ >::hxdeque ( hxsize_t dynamic_capacity_ = 0)
explicit

Constructs an empty hxdeque.

When using static storage the capacity is fixed at compile time and dynamic_capacity must be 0.

  • dynamic_capacity : Element capacity for dynamic storage.

◆ ~hxdeque()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
hxdeque< T, capacity_ >::~hxdeque ( void )

Destroys all elements in the deque.

Member Function Documentation

◆ add_range() [1/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
template<hxrange_concept_ range_t_, hxenable_if_t<!hxis_lvalue_reference< range_t_ >(), int > = 0>
void hxdeque< T, capacity_ >::add_range ( range_t_ && range_)
noexcept

Appends elements from a temporary range, moving each element with push_back.

This overload enables moving the range elements into the deque when forwarding rvalues.

  • range : The range to move elements from.

◆ add_range() [2/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
template<hxrange_concept_ range_t_>
void hxdeque< T, capacity_ >::add_range ( range_t_ & range_)
noexcept

Appends elements from a range referenced by an lvalue, copying each element with push_back.

  • range : The range to copy elements from.

◆ back() [1/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
T & hxdeque< T, capacity_ >::back ( void )

Returns a reference to the back element. The deque must not be empty.

◆ back() [2/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
const T & hxdeque< T, capacity_ >::back ( void ) const

◆ begin() [1/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
iterator hxdeque< T, capacity_ >::begin ( void )
inline

◆ begin() [2/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
const_iterator hxdeque< T, capacity_ >::begin ( void ) const
inline

Returns a const iterator pointing to the first element.

◆ capacity()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
hxsize_t hxdeque< T, capacity_ >::capacity ( void ) const

Returns the capacity of the deque or 0 if unallocated.

◆ cbegin()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
const_iterator hxdeque< T, capacity_ >::cbegin ( void ) const
inline

Returns a const iterator pointing to the first element (alias for begin).

◆ cend()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
const_iterator hxdeque< T, capacity_ >::cend ( void ) const
inline

Returns a const iterator pointing past the last element.

◆ clear()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
void hxdeque< T, capacity_ >::clear ( void )
noexcept

Destroys all elements and resets the deque to empty without deallocating.

◆ emplace_back()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
template<typename... args_t_>
void hxdeque< T, capacity_ >::emplace_back ( args_t_ &&... args_)
noexcept

Constructs an element in place at the back using forwarded arguments.

Exactly the same as push_back.

  • args : Arguments forwarded to T's constructor.

◆ emplace_front()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
template<typename... args_t_>
void hxdeque< T, capacity_ >::emplace_front ( args_t_ &&... args_)
noexcept

Constructs an element in place at the front using forwarded arguments.

Exactly the same as push_front.

  • args : Arguments forwarded to T's constructor.

◆ empty()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
bool hxdeque< T, capacity_ >::empty ( void ) const

Returns true if the deque contains no elements.

◆ end() [1/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
iterator hxdeque< T, capacity_ >::end ( void )
inline

◆ end() [2/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
const_iterator hxdeque< T, capacity_ >::end ( void ) const
inline

Returns a const iterator pointing past the last element.

◆ front() [1/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
T & hxdeque< T, capacity_ >::front ( void )

Returns a reference to the front element. The deque must not be empty.

◆ front() [2/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
const T & hxdeque< T, capacity_ >::front ( void ) const

◆ full()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
bool hxdeque< T, capacity_ >::full ( void ) const

Returns true if the deque is at capacity.

◆ max_size()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
hxsize_t hxdeque< T, capacity_ >::max_size ( void ) const
inline

Returns the capacity of the deque or 0 if unallocated.

◆ operator<()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
bool hxdeque< T, capacity_ >::operator< ( const hxdeque< T, capacity_ > & x_) const

Returns true if this deque compares less than x lexicographically, using hxkey_equal and hxkey_less.

  • x : The deque to compare against.

◆ operator==()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
bool hxdeque< T, capacity_ >::operator== ( const hxdeque< T, capacity_ > & x_) const

Returns true if this deque and x contain the same elements in the same order, using hxkey_equal.

  • x : The deque to compare against.

◆ operator[]() [1/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
T & hxdeque< T, capacity_ >::operator[] ( hxsize_t index_)

◆ operator[]() [2/2]

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
const T & hxdeque< T, capacity_ >::operator[] ( hxsize_t index_) const

Returns a const reference to the element at logical index index.

  • index : Zero-based index from the front.

◆ pop_back()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
void hxdeque< T, capacity_ >::pop_back ( void )
noexcept

Removes and destroys the back element. The deque must not be empty.

◆ pop_front()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
void hxdeque< T, capacity_ >::pop_front ( void )
noexcept

Removes and destroys the front element. The deque must not be empty.

◆ push_back()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
template<typename... args_t_>
void hxdeque< T, capacity_ >::push_back ( args_t_ &&... args_)
noexcept

Appends an element at the back using forwarded arguments.

Exactly the same as emplace_back.

  • args : Arguments forwarded to T's constructor.

◆ push_front()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
template<typename... args_t_>
void hxdeque< T, capacity_ >::push_front ( args_t_ &&... args_)
noexcept

Prepends an element at the front using forwarded arguments.

Exactly the same as emplace_front.

  • args : Arguments forwarded to T's constructor.

◆ reserve()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
void hxdeque< T, capacity_ >::reserve ( hxsize_t dynamic_capacity_)

Allocates storage for a dynamic deque.

May only be called once and only when the deque has no storage.

  • dynamic_capacity : Element capacity to allocate.

◆ size()

template<hxdeque_concept_ T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
hxsize_t hxdeque< T, capacity_ >::size ( void ) const

Returns the number of elements currently in the deque.


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