Zip and Skip Tries
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator Class Reference

Provides forward/backward iteration over the keys in the base level of the SkipTrie. More...

#include <SkipTrie.hpp>

Collaboration diagram for SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator:
Collaboration graph
[legend]

Public Member Functions

 Iterator (Node *node, Direction direction) noexcept
 Constructs an iterator.
 
Iteratoroperator++ () noexcept
 Pre-increments the iterator to the next node in its designated direction.
 
Iterator operator++ (int) noexcept
 Post-increments the iterator.
 
const KEY_Toperator* () const noexcept
 Dereferences the iterator to access the key of the current node.
 
const KEY_Toperator-> () const noexcept
 Dereferences the iterator to access the key pointer of the current node.
 
bool operator== (const Iterator &other) const noexcept
 Compares this iterator with another for equality.
 
bool operator!= (const Iterator &other) const noexcept
 Compares this iterator with another for inequality.
 

Private Attributes

Nodem_node
 Pointer to the current node the iterator is positioned at.
 
Direction m_direction
 The direction the iterator moves upon incrementing.
 

Detailed Description

template<typename CHAR_T, unsigned CHAR_SIZE_BITS = sizeof(CHAR_T) * 8>
class SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator

Provides forward/backward iteration over the keys in the base level of the SkipTrie.

Allows traversal through the nodes at level 0 using standard iterator operations (++, *, ->, ==, !=). Can be constructed to move FORWARD or BACKWARD.

Definition at line 392 of file SkipTrie.hpp.

Constructor & Destructor Documentation

◆ Iterator()

template<typename CHAR_T , unsigned CHAR_SIZE_BITS>
SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator::Iterator ( Node node,
Direction  direction 
)
noexcept

Constructs an iterator.

Parameters
nodeA pointer to the starting Node for the iterator (usually a node at level 0).
directionThe direction (FORWARD or BACKWARD) the iterator will move upon incrementing.

Definition at line 483 of file SkipTrie.hpp.

485{
486 // Constructor body intentionally empty
487}
Node * m_node
Pointer to the current node the iterator is positioned at.
Definition SkipTrie.hpp:443
Direction m_direction
The direction the iterator moves upon incrementing.
Definition SkipTrie.hpp:445
T * alloc_to_device(size_t size)
Allocates memory on the CUDA device.

Member Function Documentation

◆ operator!=()

template<typename CHAR_T , unsigned CHAR_SIZE_BITS>
bool SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator::operator!= ( const Iterator other) const
noexcept

Compares this iterator with another for inequality.

Parameters
otherThe iterator to compare against.
Returns
bool True if the iterators point to different Nodes, false otherwise.

Definition at line 523 of file SkipTrie.hpp.

524{
525 return !(*this == other); // Delegate to operator==
526}

◆ operator*()

template<typename CHAR_T , unsigned CHAR_SIZE_BITS>
const BitString< CHAR_T, CHAR_SIZE_BITS > & SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator::operator* ( ) const
noexcept

Dereferences the iterator to access the key of the current node.

Returns
const KEY_T& A constant reference to the BitString key at the iterator's current position.

Definition at line 505 of file SkipTrie.hpp.

506{
507 return *m_node->key;
508}
const KEY_T * key
Pointer to the key associated with this node. The SkipTrie does not own the key data.
Definition SkipTrie.hpp:226

◆ operator++() [1/2]

template<typename CHAR_T , unsigned CHAR_SIZE_BITS>
SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator & SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator::operator++ ( )
noexcept

Pre-increments the iterator to the next node in its designated direction.

Returns
Iterator& A reference to the incremented iterator.

Definition at line 490 of file SkipTrie.hpp.

491{
493 return *this;
494}
Node * next_node(Direction direction) const noexcept
Retrieves the neighboring node in the specified direction on the same level.
Definition SkipTrie.hpp:558

◆ operator++() [2/2]

template<typename CHAR_T , unsigned CHAR_SIZE_BITS>
SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator::operator++ ( int  )
noexcept

Post-increments the iterator.

Returns
Iterator A copy of the iterator before it was incremented.
Note
Prefer pre-increment (++it) for potentially better performance.

Definition at line 497 of file SkipTrie.hpp.

498{
499 Iterator temp = *this;
500 ++(*this); // Use pre-increment
501 return temp;
502}
Iterator(Node *node, Direction direction) noexcept
Constructs an iterator.
Definition SkipTrie.hpp:483

◆ operator->()

template<typename CHAR_T , unsigned CHAR_SIZE_BITS>
const BitString< CHAR_T, CHAR_SIZE_BITS > * SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator::operator-> ( ) const
noexcept

Dereferences the iterator to access the key pointer of the current node.

Returns
const KEY_T* A constant pointer to the BitString key at the iterator's current position.

Definition at line 511 of file SkipTrie.hpp.

512{
513 return m_node->key;
514}

◆ operator==()

template<typename CHAR_T , unsigned CHAR_SIZE_BITS>
bool SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator::operator== ( const Iterator other) const
noexcept

Compares this iterator with another for equality.

Parameters
otherThe iterator to compare against.
Returns
bool True if both iterators point to the same Node, false otherwise.

Definition at line 517 of file SkipTrie.hpp.

518{
519 return m_node == other.m_node;
520}

Member Data Documentation

◆ m_direction

template<typename CHAR_T , unsigned CHAR_SIZE_BITS = sizeof(CHAR_T) * 8>
Direction SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator::m_direction
private

The direction the iterator moves upon incrementing.

Definition at line 445 of file SkipTrie.hpp.

◆ m_node

template<typename CHAR_T , unsigned CHAR_SIZE_BITS = sizeof(CHAR_T) * 8>
Node* SkipTrie< CHAR_T, CHAR_SIZE_BITS >::Iterator::m_node
private

Pointer to the current node the iterator is positioned at.

Definition at line 443 of file SkipTrie.hpp.


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