#include <LimitedQueue.hpp>
|
| LimitedQueue (size_t limit=1000) |
|
bool | empty () const |
| Return true if the buffer is empty. More...
|
|
boost::optional< T > | get (size_t index) const |
| Value Accessors. More...
|
|
boost::optional< T > | first () const |
| Get the first item from the queue. More...
|
|
boost::optional< T > | last () const |
| Get the last item from the queue. More...
|
|
void | clear () |
| Modifiers. More...
|
|
bool | pushBack (const T &item, T &deleted) |
| Push an item to the end of the queue. More...
|
|
bool | pushBack (const T &item) |
| Push an item to the end of the queue. More...
|
|
std::vector< T > | pushFront (const std::vector< T > &items) |
| Push items into beginning of queue. More...
|
|
template<typename Equals = std::equal_to<T>> |
int | replaceItem (const T &needle, const T &replacement) |
| Replace the needle with the given item. More...
|
|
bool | replaceItem (size_t index, const T &replacement) |
| Replace the item at index with the given item. More...
|
|
template<typename Equals = std::equal_to<T>> |
bool | insertBefore (const T &needle, const T &item) |
| Inserts the given item before another item. More...
|
|
template<typename Equals = std::equal_to<T>> |
bool | insertAfter (const T &needle, const T &item) |
| Inserts the given item after another item. More...
|
|
LimitedQueueSnapshot< T > | getSnapshot () const |
|
template<typename Predicate > |
boost::optional< T > | find (Predicate pred) const |
| Returns the first item matching a predicate. More...
|
|
template<typename Predicate > |
boost::optional< T > | rfind (Predicate pred) const |
| Returns the first item matching a predicate, checking in reverse. More...
|
|
◆ LimitedQueue()
◆ clear()
◆ empty()
Return true if the buffer is empty.
◆ find()
template<typename T>
template<typename Predicate >
Returns the first item matching a predicate.
The contents of the LimitedQueue are iterated over from front to back until the first element that satisfies pred(item)
. If no item satisfies the predicate, or if the queue is empty, then boost::none is returned.
- Parameters
-
[in] | pred | predicate that will be applied to items |
- Returns
- the first item found or boost::none
◆ first()
Get the first item from the queue.
- Returns
- the item at the front of the queue if it's populated, or none the queue is empty
◆ get()
Value Accessors.
Get the item at the given index safely
- Parameters
-
[in] | index | the index of the item to fetch |
- Returns
- the item at the index if it's populated, or none if it's not
◆ getSnapshot()
◆ insertAfter()
template<typename T>
template<typename Equals = std::equal_to<T>>
Inserts the given item after another item.
- Parameters
-
[in] | needle | the item to use as positional reference |
[in] | item | the item to insert after needle |
- Template Parameters
-
Equality | function object to use for comparison |
- Returns
- true if an insertion took place
◆ insertBefore()
template<typename T>
template<typename Equals = std::equal_to<T>>
Inserts the given item before another item.
- Parameters
-
[in] | needle | the item to use as positional reference |
[in] | item | the item to insert before needle |
- Template Parameters
-
Equality | function object to use for comparison |
- Returns
- true if an insertion took place
◆ last()
Get the last item from the queue.
- Returns
- the item at the back of the queue if it's populated, or none the queue is empty
◆ pushBack() [1/2]
Push an item to the end of the queue.
- Parameters
-
| item | the item to push |
[out] | deleted | the item that was deleted |
- Returns
- true if an element was deleted to make room
◆ pushBack() [2/2]
Push an item to the end of the queue.
- Parameters
-
- Returns
- true if an element was deleted to make room
◆ pushFront()
Push items into beginning of queue.
Items are inserted in reverse order. Items will only be inserted if they fit, meaning no elements can be deleted from using this function.
- Parameters
-
items | the vector of items to push |
- Returns
- vector of elements that were pushed
◆ replaceItem() [1/2]
template<typename T>
template<typename Equals = std::equal_to<T>>
Replace the needle with the given item.
- Parameters
-
[in] | needle | the item to search for |
[in] | replacement | the item to replace needle with |
- Template Parameters
-
Equality | function object to use for comparison |
- Returns
- the index of the replaced item, or -1 if no replacement took place
◆ replaceItem() [2/2]
Replace the item at index with the given item.
- Parameters
-
[in] | index | the index of the item to replace |
[in] | replacement | the item to put in place of the item at index |
- Returns
- true if a replacement took place
◆ rfind()
template<typename T>
template<typename Predicate >
Returns the first item matching a predicate, checking in reverse.
The contents of the LimitedQueue are iterated over from back to front until the first element that satisfies pred(item)
. If no item satisfies the predicate, or if the queue is empty, then boost::none is returned.
- Parameters
-
[in] | pred | predicate that will be applied to items |
- Returns
- the first item found or boost::none
The documentation for this class was generated from the following file: