Blink DB Documentation v1.0.0
Blink DB Documentation
Loading...
Searching...
No Matches
SkipList Class Reference

Skip List Class. More...

#include <skiplist.hpp>

Classes

class  Iterator
 A Iterator class for the skip list. More...

Public Member Functions

Nodesearch (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)

Detailed Description

Skip List Class.

This class implements a skip list data structure for efficient key-value storage and retrieval.

Member Function Documentation

◆ get()

std::pair< bool, std::string > SkipList::get ( const std::string & key)
inline

This method retrieves the value associated with a given key in the skip list.

Parameters
keyThe key to search for.
Returns
std::pair<bool, std::string> A pair containing a boolean indicating whether the key was found and the corresponding value if found, or an empty string if not found.

◆ getSize()

size_t SkipList::getSize ( )
inline

Get the size of the skip list.

Returns
size_t The total size of the skip list in bytes.

◆ put()

void SkipList::put ( const std::string & key,
const std::string & value )
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.

Parameters
keyThe key to insert.
valueThe value to associate with the key.

◆ search()

Node * SkipList::search ( const std::string & 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.

Parameters
keyThe key to search for.
Returns
Node* A pointer to the node containing the key or the node where the key should be inserted.

The documentation for this class was generated from the following file: