|
loon
High-performance header-only C++ library for low-latency applications
|
A Redis-compatible list supporting operations from both ends. More...
#include <redis_list.hpp>
Public Member Functions | |
| RedisList () | |
| Constructs an empty RedisList. | |
| ~RedisList ()=default | |
| Default destructor. | |
| RedisList (const RedisList &other)=default | |
| Copy constructor. | |
| RedisList (RedisList &&other) noexcept=default | |
| Move constructor. | |
| RedisList (std::vector< T > &&other) | |
| Constructs a RedisList from a vector by moving its elements. | |
| RedisList & | operator= (const RedisList &other)=default |
| Copy assignment operator. | |
| RedisList & | operator= (RedisList &&other) noexcept=default |
| Move assignment operator. | |
| size_t | lpush (const T &value) |
| Pushes a value to the front of the list (left push). | |
| size_t | lpush (T &&value) |
| Pushes a value to the front of the list (left push). | |
| size_t | rpush (const T &value) |
| Pushes a value to the back of the list (right push). | |
| size_t | rpush (T &&value) |
| Pushes a value to the back of the list (right push). | |
| std::optional< T > | lpop () |
| Removes and returns the first element (left pop). | |
| std::vector< T > | lpop (size_t count) |
| Removes and returns up to count elements from the front. | |
| std::optional< T > | rpop () |
| Removes and returns the last element (right pop). | |
| std::vector< T > | rpop (size_t count) |
| Removes and returns up to count elements from the back. | |
| std::vector< T > | lrange (int start, int stop) const |
| Returns a range of elements without removing them. | |
| size_t | llen () const |
| Returns the length of the list (Redis LLEN command). | |
| size_t | size () const |
| Returns the number of elements in the list. | |
| bool | empty () const |
| Checks if the list is empty. | |
A Redis-compatible list supporting operations from both ends.
RedisList provides a double-ended queue with an API modeled after Redis list commands. It supports efficient O(1) push/pop operations at both ends and O(n) range queries.
| T | Element type stored in the list. |
Definition at line 28 of file redis_list.hpp.
|
inlineexplicit |
Constructs a RedisList from a vector by moving its elements.
| other | Vector to move elements from. |
Definition at line 44 of file redis_list.hpp.
|
inline |
Checks if the list is empty.
Definition at line 169 of file redis_list.hpp.
Referenced by loon::RedisList< T >::lpop(), and loon::RedisList< T >::rpop().
|
inline |
Returns the length of the list (Redis LLEN command).
Definition at line 161 of file redis_list.hpp.
References loon::RedisList< T >::size().
|
inline |
Removes and returns the first element (left pop).
Definition at line 87 of file redis_list.hpp.
References loon::RedisList< T >::empty().
|
inline |
Removes and returns up to count elements from the front.
| count | Maximum number of elements to remove. |
Definition at line 99 of file redis_list.hpp.
|
inline |
Pushes a value to the front of the list (left push).
| value | The value to push (copied). |
Definition at line 56 of file redis_list.hpp.
|
inline |
Pushes a value to the front of the list (left push).
| value | The value to push (moved). |
Definition at line 64 of file redis_list.hpp.
|
inline |
Returns a range of elements without removing them.
Supports negative indices: -1 is the last element, -2 is second to last, etc. The range is inclusive on both ends (unlike typical C++ iterators).
| start | Starting index (inclusive, can be negative). |
| stop | Ending index (inclusive, can be negative). |
Definition at line 143 of file redis_list.hpp.
References loon::RedisList< T >::size().
|
inline |
Removes and returns the last element (right pop).
Definition at line 109 of file redis_list.hpp.
References loon::RedisList< T >::empty().
|
inline |
Removes and returns up to count elements from the back.
| count | Maximum number of elements to remove. |
Definition at line 121 of file redis_list.hpp.
|
inline |
Pushes a value to the back of the list (right push).
| value | The value to push (copied). |
Definition at line 72 of file redis_list.hpp.
|
inline |
Pushes a value to the back of the list (right push).
| value | The value to push (moved). |
Definition at line 80 of file redis_list.hpp.
|
inline |
Returns the number of elements in the list.
Definition at line 165 of file redis_list.hpp.
Referenced by loon::RedisList< T >::llen(), and loon::RedisList< T >::lrange().