|
Zero
0.1.0
|
Deque with Direct Access. More...
#include <hashtable_deque.hpp>
Classes | |
| class | KeyPair |
| A pair of keys for the implementation of a deque as a doubly-linked list. More... | |
Public Member Functions | |
| HashtableDeque (key_type initialSize=0) | |
| Constructor of a Deque with Direct Access. More... | |
| ~HashtableDeque () | |
| Destructor of a Deque with Direct Access. More... | |
| bool | contains (const key_type &k) const noexcept |
| Entry with given key contained. More... | |
| void | pushToBack (const key_type &k) |
| Add the key to the back of this deque. More... | |
| void | pushToBack (key_type &&k) |
| Add the key to the back of this deque (with move semantics) More... | |
| void | popFromFront () |
| Removes the next key from this deque. More... | |
| void | popFromFront (key_type &k) |
| Removes the next key from this deque. More... | |
| void | pushToFront (const key_type &k) |
| Add the key to the front of this deque. More... | |
| void | pushToFront (key_type &&k) |
| Add the key to the front of this deque (with move semantics) More... | |
| void | popFromBack () |
| Removes the next key from this deque. More... | |
| void | popFromBack (key_type &k) |
| Removes the next key from this deque. More... | |
| void | remove (const key_type &k) |
| Removes a specific key from this deque. More... | |
| void | remove (key_type &&k) |
| Removes a specific key from this deque (with move semantic) More... | |
| void | insertBefore (const key_type &k, const key_type &ref) |
| Add the key to before a reference key. More... | |
| void | insertBefore (key_type &&k, key_type &&ref) |
| Add the key to before a reference key. More... | |
| void | insertAfter (const key_type &k, const key_type &ref) |
| Add the key to after a reference key. More... | |
| void | insertAfter (key_type &&k, key_type &&ref) |
| Add the key to after a reference key. More... | |
| void | getFront (key_type &k) |
| Get the key at the front. More... | |
| key_type | getFront () |
| Get the key at the front. More... | |
| void | getBack (key_type &k) |
| Get the key at the back. More... | |
| key_type | getBack () |
| Get the key at the back. More... | |
| void | getBefore (key_type &k, const key_type &ref) |
| Get the key to before a reference key. More... | |
| void | getBefore (key_type &k, key_type &&ref) |
| Get the key to before a reference key. More... | |
| key_type | getBefore (const key_type &ref) |
| Get the key to before a reference key. More... | |
| key_type | getBefore (key_type &&ref) |
| Get the key to before a reference key. More... | |
| void | getAfter (key_type &k, const key_type &ref) |
| Get the key to after a reference key. More... | |
| void | getAfter (key_type &k, key_type &&ref) |
| Get the key to after a reference key. More... | |
| key_type | getAfter (const key_type &ref) |
| key_type | getAfter (key_type &&ref) |
| uint64_t | length () const noexcept |
| Number of entries in this deque. More... | |
Private Attributes | |
| std::unique_ptr< std::unordered_map< key_type, KeyPair > > | _directAccessDeque |
| Maps from keys to their deque entry. More... | |
| key_type | _back |
| Element at the back. More... | |
| key_type | _front |
| Element at the front. More... | |
Deque with Direct Access.
Represents a deque of keys with direct access using the keys. It offers the usual deque semantics where entries are inserted either at the back or the front of the deque and where entries are removed either from the front or from the back of it. But it also offers the possibility to remove a specified element from somewhere within the deque. The data type of the entries is specified using a template parameter. Each value contained in the deque needs to be unique and inserts of duplicate keys are prevented. The computational complexity of the direct access as well as removal and insertion with deque semantics depends on the implementation of std::unordered_map, as this class is used for that. The space complexity also depends on the implementation of std::unordered_map where key has a size of the key template parameter and where T has double the size of the key template parameter.
Boost.MultiIndex .| key_type | The data type of the entries stored in this data structure. |
| invalid_key | This specifies an invalid key which can be used to mark that an element in the deque does not have a previous or next element. It can also be used to mark that there is no back or front of the deque when there is no deque. This should have the semantics of null for the specified key template parameter therefore a natural choice for the case that key is a pointer would be nullptr . |
|
inline |
Constructor of a Deque with Direct Access.
Creates a new Deque with Direct Access with an optional maximum size. If the initialSize is greater 0, the memory required for the specified number of keys is allocated during the creation to reduce the overhead due to allocation of memory.
| initialSize | The maximum number of keys that can be managed by this Deque with Direct Access, or 0 (default) for a Deque with Direct Access with an unlimited capacity (depends on the number of unique key values). |
|
inline |
Destructor of a Deque with Direct Access.
Destructs this Deque with Direct Access including the dynamically allocated memory used for the data.
|
inlinenoexcept |
Entry with given key contained.
Searches this deque for the given key and the return value gives information about if the key could be found.
| k | The key that should be searched for in this deque. |
true if this deque contains an entry with k as key, false else.
|
inline |
Get the key to after a reference key.
Returns an entry right after (closer to the back of the deque) a given reference key already contained in this deque.
| [out] | k | The key after the reference key. |
| ref | The already contained key given as position. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyAtTheBackException | Thrown if the reference key was already at the back of this deque. |
Returns an entry right after (closer to the back of the deque) a given reference key already contained in this deque.
| ref | The already contained key given as position. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyAtTheBackException | Thrown if the reference key was already at the back of this deque. |
|
inline |
Get the key to after a reference key.
Returns an entry right after (closer to the back of the deque) a given reference key already contained in this deque.
| [out] | k | The key after the reference key. |
| ref | The already contained key given as position. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyAtTheBackException | Thrown if the reference key was already at the back of this deque. |
Returns an entry right after (closer to the back of the deque) a given reference key already contained in this deque.
| ref | The already contained key given as position. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyAtTheBackException | Thrown if the reference key was already at the back of this deque. |
|
inline |
|
inline |
|
inline |
Get the key at the back.
Returns the entry at the back of this deque.
| [out] | k | The key at the back. |
| HashtableDequeEmptyException | Thrown if this deque is empty. |
|
inline |
Get the key at the back.
Returns the entry at the back of this deque.
| HashtableDequeEmptyException | Thrown if this deque is empty. |
|
inline |
Get the key to before a reference key.
Returns an entry right before (closer to the front of the deque) a given reference key already contained in this deque.
| [out] | k | The key before the reference key. |
| ref | The already contained key given as position. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyAtTheFrontException | Thrown if the reference key was already at the front of this deque. |
|
inline |
Get the key to before a reference key.
Returns an entry right before (closer to the front of the deque) a given reference key already contained in this deque.
| [out] | k | The key before the reference key. |
| ref | The already contained key given as position. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyAtTheFrontException | Thrown if the reference key was already at the front of this deque. |
|
inline |
Get the key to before a reference key.
Returns an entry right before (closer to the front of the deque) a given reference key already contained in this deque.
| ref | The already contained key given as position. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyAtTheFrontException | Thrown if the reference key was already at the front of this deque. |
|
inline |
Get the key to before a reference key.
Returns an entry right before (closer to the front of the deque) a given reference key already contained in this deque.
| ref | The already contained key given as position. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyAtTheFrontException | Thrown if the reference key was already at the front of this deque. |
|
inline |
Get the key at the front.
Returns the entry at the front of this deque.
| [out] | k | The key at the front. |
| HashtableDequeEmptyException | Thrown if this deque is empty. |
|
inline |
Get the key at the front.
Returns the entry at the front of this deque.
| HashtableDequeEmptyException | Thrown if this deque is empty. |
|
inline |
Add the key to after a reference key.
Adds an entry right after (closer to the back of the deque) a given reference key already contained in this deque.
| k | The key that is added to this deque. |
| ref | The already contained key given as position for the insert. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyContainsException | Thrown if the key was already contained in this deque. |
|
inline |
Add the key to after a reference key.
Adds an entry right after (closer to the back of the deque) a given reference key already contained in this deque.
| k | The key that is added to this deque. |
| ref | The already contained key given as position for the insert. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyContainsException | Thrown if the key was already contained in this deque. |
|
inline |
Add the key to before a reference key.
Adds an entry right before (closer to the front of the deque) a given reference key already contained in this deque.
| k | The key that is added to this deque. |
| ref | The already contained key given as position for the insert. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyContainsException | Thrown if the key was already contained in this deque. |
|
inline |
Add the key to before a reference key.
Adds an entry right before (closer to the front of the deque) a given reference key already contained in this deque.
| k | The key that is added to this deque. |
| ref | The already contained key given as position for the insert. |
| HashtableDequeNotContainedException | Thrown if the reference key was not already contained in this deque. |
| HashtableDequeAlreadyContainsException | Thrown if the key was already contained in this deque. |
|
inlinenoexcept |
Number of entries in this deque.
Returns the number of entries (keys) that are contained in this deque.
|
inline |
Removes the next key from this deque.
Removes an entry from the back of this deque.
| HashtableDequeEmptyException | Thrown if this deque was already empty. |
|
inline |
Removes the next key from this deque.
Removes an entry from the back of this deque.
| [out] | k | The key that was removed from the front of this queue. |
| HashtableDequeEmptyException | Thrown if this deque was already empty. |
|
inline |
Removes the next key from this deque.
Removes an entry from the front of this deque.
| HashtableDequeEmptyException | Thrown if this deque was already empty. |
|
inline |
Removes the next key from this deque.
Removes an entry from the front of this deque.
| [out] | k | The key that was removed from the front of this queue. |
| HashtableDequeEmptyException | Thrown if this deque was already empty. |
|
inline |
Add the key to the back of this deque.
Adds an entry to the back of this deque.
| k | The key that is added to this deque. |
| HashtableDequeAlreadyContainsException | Thrown if the key was already contained in this deque. |
|
inline |
Add the key to the back of this deque (with move semantics)
Adds an entry to the back of this deque using move semantics.
| k | The key that is added to this deque. |
| HashtableDequeAlreadyContainsException | Thrown if the key was already contained in this deque. |
|
inline |
Add the key to the front of this deque.
Adds an entry to the front of this deque.
| k | The key that is added to this deque. |
| HashtableDequeAlreadyContainsException | Thrown if the key was already contained in this deque. |
|
inline |
Add the key to the front of this deque (with move semantics)
Adds an entry to the front of this deque using move semantics.
| k | The key that is added to this deque. |
| HashtableDequeAlreadyContainsException | Thrown if the key was already contained in this deque. |
|
inline |
Removes a specific key from this deque.
Removes the specified key k from this deque using the hash table over the deque entries, if the key k was contained in this deque.
| k | The key to remove from this deque. |
| HashtableDequeNotContainedException | Thrown if the key was not contained in this deque. |
|
inline |
Removes a specific key from this deque (with move semantic)
Removes the specified key k from this deque using the hash table over the deque entries and move semantics, if the key k was contained in this deque.
| k | The key to remove from this deque. |
| HashtableDequeNotContainedException | Thrown if the key was not contained in this deque. |
|
private |
Element at the back.
Stores the key of the element at the back of the deque. This element does not have a next element but the previous element can be accesses using _directAccessDeque .
|
private |
Maps from keys to their deque entry.
Allows direct access to specific elements of the deque and stores the inner deque elements. Every access on deque elements happens through the interface of this data structure but this does not directly support the access with deque semantics. The key represents an deque entry and the keyPair which is mapped to that key stores the information about previous and next key in the deque.
|
private |
Element at the front.
Stores the key of the element at the front of the deque. This element does not have a previous element but the next element can be accesses using _directAccessDeque .
1.8.12