Go to the documentation of this file.
38 #ifndef __BASE_CIRCULAR_QUEUE_HH__
39 #define __BASE_CIRCULAR_QUEUE_HH__
45 #include <type_traits>
90 using typename Base::reference;
91 using typename Base::const_reference;
109 return (op1 + op2) %
size;
116 int32_t ret =
sub(op1, op2,
size);
117 return ret >= 0 ? ret : ret +
size;
121 sub(uint32_t op1, uint32_t op2, uint32_t
size)
124 return (op1 - op2) %
size;
126 return -((op2 - op1) %
size);
185 static_assert(std::is_same<reference, T&>::value,
186 "reference type is not assignable as required");
264 return !(*
this == that);
295 return &((*_cq)[
_idx]);
303 return &((*_cq)[
_idx]);
459 if (this->_round != that.
_round) {
471 template<
typename Idx>
484 return (this->_round < that.
_round) ||
493 {
return !(*
this <= that); }
499 {
return !(*
this < that); }
505 {
return !(that < *
this); }
517 using Base::operator[];
597 _head <= idx || _head >
_tail)) ||
665 if (num_elem == 0)
return;
668 assert(hIt <=
end());
725 for (
auto idx = 0; idx <
len; idx++)
790 return iterator(
this, poi, round);
802 return iterator(
const_cast<CircularQueue*
>(
this), poi, round);
826 return iterator(
this, idx, round);
pointer operator->()
Dereference operator.
void decrease(uint32_t &v)
static uint32_t moduloSub(uint32_t op1, uint32_t op2, uint32_t size)
General modular subtraction.
std::ptrdiff_t difference_type
const value_type & const_reference
void advance_tail()
Increases the tail by one.
bool dereferenceable() const
Test dereferenceability.
iterator operator+(const difference_type &t)
Addition operator.
difference_type operator-(const iterator &that)
Difference operator.
friend iterator operator+(const difference_type &t, iterator &it)
iterator getIterator(size_t idx)
Return an iterator to an index in the vector.
iterator operator++(int)
Post-increment operator.
uint32_t moduloSub(uint32_t s1, uint32_t s2) const
iterator & operator--()
Pre-decrement operator.
const_reference operator*() const
T value_type
Iterator Traits.
void pop_back()
Circularly decrease the tail pointer.
iterator operator-(const difference_type &t)
Substraction operator.
iterator begin()
Iterators.
static int32_t sub(uint32_t op1, uint32_t op2, uint32_t size)
std::enable_if< std::is_integral< Idx >::value, reference >::type operator[](const Idx &index)
Index operator.
void flush()
Remove all the elements in the queue.
Iterator to the circular queue.
iterator & operator++()
Pre-increment operator.
bool full() const
Is the queue full? A queue is full if the head is the 0^{th} element and the tail is the (size-1)^{th...
bool operator>(const iterator &that) const
iterator & operator+=(const difference_type &t)
RandomAccessIterator requirements.
const value_type * const_pointer
iterator operator--(int)
Post-decrement operator.
iterator(const iterator &it)
size_t idx() const
OutputIterator has no extra requirements.
bool isValidIdx(size_t idx, uint32_t round) const
Test if the index is in the range of valid elements.
iterator & operator-=(const difference_type &t)
void push_back(typename Base::value_type val)
Pushes an element at the end of the queue.
uint32_t _round
Counter for how many times the tail wraps around.
bool decrementable() const
ForwardIterator The multipass guarantee is provided by the reliance on _idx.
void increase(uint32_t &v, size_t delta=1)
bool operator>=(const iterator &that) const
void pop_front(size_t num_elem=1)
Circularly increase the head pointer.
bool operator<=(const iterator &that) const
bool operator<(const iterator &that) const
Comparisons.
reference operator*()
Dereference operator.
bool empty() const
Is the queue empty?
friend iterator operator-(const difference_type &t, iterator &it)
std::random_access_iterator_tag iterator_category
uint32_t moduloAdd(uint32_t s1, uint32_t s2) const
bool operator==(const iterator &that) const
InputIterator.
bool operator!=(const iterator &that)
Inequality operator.
const_pointer operator->() const
static uint32_t moduloAdd(uint32_t op1, uint32_t op2, uint32_t size)
General modular addition.
iterator & operator=(const iterator &it)
bool isValidIdx(size_t idx) const
Test if the index is in the range of valid elements.
CircularQueue(uint32_t size=0)
void advance_tail(uint32_t len)
Increases the tail by a specified number of steps.
iterator(CircularQueue *cq, uint32_t idx, uint32_t round)
iterator()
Trait reference type iterator satisfies OutputIterator, therefore reference must be T&.
Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17