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

#include <hxdeque.hpp>

Public Member Functions

 hxdeque (hxsize_t dynamic_capacity_=0)
 ~hxdeque (void)
T & operator[] (hxsize_t index_)
const T & operator[] (hxsize_t index_) const
T & at (hxsize_t index_)
const T & at (hxsize_t index_) const
T & back (void)
const T & back (void) const
hxsize_t capacity (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
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<typename 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 Θ(1). The capacity must be a power of two and greater than zero. This is designed to do one thing very well and that is all.

Constructor & Destructor Documentation

◆ hxdeque()

template<typename 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.

  • dynamic_capacity : Element capacity for dynamic storage.

◆ ~hxdeque()

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

Destroys all elements in the deque.

Member Function Documentation

◆ at() [1/2]

template<typename T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
T & hxdeque< T, capacity_ >::at ( hxsize_t index_)

Returns a reference to the element at logical index index.

  • index : Zero-based index from the front.

◆ at() [2/2]

template<typename T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
const T & hxdeque< T, capacity_ >::at ( hxsize_t index_) const

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

  • index : Zero-based index from the front.

◆ back() [1/2]

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

Returns a reference to the back element.

◆ back() [2/2]

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

Returns a const reference to the back element.

◆ capacity()

template<typename 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.

◆ clear()

template<typename 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<typename 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<typename 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<typename T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
bool hxdeque< T, capacity_ >::empty ( void ) const

Returns true if the deque contains no elements.

◆ front() [1/2]

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

Returns a reference to the front element.

◆ front() [2/2]

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

Returns a const reference to the front element.

◆ full()

template<typename 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<typename T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
hxsize_t hxdeque< T, capacity_ >::max_size ( void ) const
inline

Returns the capacity of the deque.

◆ operator[]() [1/2]

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

Returns a reference to the element at logical index index.

  • index : Zero-based index from the front.

◆ operator[]() [2/2]

template<typename 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<typename T, hxsize_t capacity_ = hxallocator_dynamic_capacity>
void hxdeque< T, capacity_ >::pop_back ( void )
noexcept

Removes and destroys the back element.

◆ pop_front()

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

Removes and destroys the front element.

◆ push_back()

template<typename 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<typename 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<typename 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<typename 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: