Skip List Class. More...
#include <skiplist.hpp>
Classes | |
| class | Iterator |
| A Iterator class for the skip list. More... | |
Public Member Functions | |
| Node * | search (const std::string &key) |
| Search for a key in the skip list. | |
| std::pair< bool, std::string > | get (const std::string &key) |
| This method retrieves the value associated with a given key in the skip list. | |
| void | put (const std::string &key, const std::string &value) |
| This method inserts a key-value pair into the skip list. | |
| size_t | getSize () |
| Get the size of the skip list. | |
| Iterator | begin () |
| Iterator | end () |
| Iterator | find (const std::string &key) |
Skip List Class.
This class implements a skip list data structure for efficient key-value storage and retrieval.
|
inline |
This method retrieves the value associated with a given key in the skip list.
| key | The key to search for. |
|
inline |
Get the size of the skip list.
|
inline |
This method inserts a key-value pair into the skip list.
As the skip-list is a probabilistic data structure, the insertion may cause the skip-list to grow in height. The method handles this by creating new levels as needed. The insertion is done in a way that maintains the skip-list properties.
| key | The key to insert. |
| value | The value to associate with the key. |
|
inline |
Search for a key in the skip list.
This method traverses the skip list to find the node with the specified key. It starts from the head and moves down to the lower levels until it finds the key or reaches the end. The search is performed in a forward direction, skipping nodes that are not relevant. if the key is not found, it returns the node where the key should be inserted.
| key | The key to search for. |