Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare > Class Template Reference

Class that represents a stack of references to other nodes. More...

Public Member Functions

 SwappableNodeRefStack ()
const NodeRef< T, _Compare > & operator[] (size_t level) const
NodeRef< T, _Compare > & operator[] (size_t level)
size_t height () const
 Number of nodes referenced.
size_t swapLevel () const
 The current swap level.
bool canSwap () const
 true if a swap can take place _swapLevel < height()
bool noNodePointerMatches (const Node< T, _Compare > *p) const
bool allNodePointerMatch (const Node< T, _Compare > *p) const
void push_back (Node< T, _Compare > *p, size_t w)
 Add a new reference.
void pop_back ()
 Remove top reference.
void swap (SwappableNodeRefStack< T, _Compare > &val)
void resetSwapLevel ()
 Reset the swap level (for example before starting a remove).
void incSwapLevel ()
IntegrityCheck lacksIntegrity () const
size_t size_of () const
void clear ()

Protected Attributes

std::vector< struct NodeRef< T, _Compare > > _nodes
 Stack of NodeRef node references.
size_t _swapLevel
 The current swap level.

Private Member Functions

 SwappableNodeRefStack (const SwappableNodeRefStack &that)
 Prevent cctor.
SwappableNodeRefStack & operator= (const SwappableNodeRefStack &that) const
 Prevent operator=.

Detailed Description

template<typename T, typename _Compare>
class duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >

Class that represents a stack of references to other nodes.

Each reference is a NodeRef so a pointer to a Node and a width. This just does simple bookkeeping on this stack.

It also facilitates swapping references with another SwappableNodeRefStack when inserting or removing a Node.

Template Parameters
TThe type of the Skip List Node values.
_CompareA comparison function for type T.

Constructor & Destructor Documentation

◆ SwappableNodeRefStack()

template<typename T, typename _Compare>
duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::SwappableNodeRefStack ( )
inline

Constructor. Initialises the swap level to 0.

Here is the caller graph for this function:

Member Function Documentation

◆ operator[]() [1/2]

template<typename T, typename _Compare>
const NodeRef< T, _Compare > & duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::operator[] ( size_t level) const

The readable NodeRef at the given level.

Template Parameters
TThe type of the Skip List Node values.
_CompareA comparison function for type T.
Parameters
levelThe level.
Returns
A reference to the Node.
486368 {
486369 // NOTE: No bounds checking on vector::operator[], so this assert will do
486370 assert(level < _nodes.size());
486371 return _nodes[level];
Class that represents a stack of references to other nodes.
Definition duckdb.cpp:486278
std::vector< struct NodeRef< T, _Compare > > _nodes
Stack of NodeRef node references.
Definition duckdb.cpp:486346
#define assert(x)
Definition duckdb.cpp:486071

◆ operator[]() [2/2]

template<typename T, typename _Compare>
NodeRef< T, _Compare > & duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::operator[] ( size_t level)

The writeable NodeRef at the given level.

Template Parameters
TThe type of the Skip List Node values.
_CompareA comparison function for type T.
Parameters
levelThe level.
Returns
A reference to the Node.
486383 {
486384 // NOTE: No bounds checking on vector::operator[], so this assert will do
486385 assert(level < _nodes.size());
486386 return _nodes[level];

◆ height()

template<typename T, typename _Compare>
size_t duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::height ( ) const
inline

Number of nodes referenced.

486294 {
486295 return _nodes.size();
Here is the caller graph for this function:

◆ swapLevel()

template<typename T, typename _Compare>
size_t duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::swapLevel ( ) const
inline

The current swap level.

Here is the caller graph for this function:

◆ canSwap()

template<typename T, typename _Compare>
bool duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::canSwap ( ) const
inline

true if a swap can take place _swapLevel < height()

Here is the call graph for this function:
Here is the caller graph for this function:

◆ noNodePointerMatches()

template<typename T, typename _Compare>
bool duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::noNodePointerMatches ( const Node< T, _Compare > * p) const

Whether all node references are swapped. Should be true after an insert operation.

Template Parameters
TThe type of the Skip List Node values.
_CompareA comparison function for type T.
Parameters
pThe Node.
Returns
true if all the Node references are swapped (none are referring to the given Node).
486399 {
486400 for (size_t level = height(); level-- > 0;) {
486401 if (p == _nodes[level].pNode) {
486402 return false;
486403 }
486404 }
486405 return true;
size_t height() const
Number of nodes referenced.
Definition duckdb.cpp:486293
Here is the call graph for this function:
Here is the caller graph for this function:

◆ allNodePointerMatch()

template<typename T, typename _Compare>
bool duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::allNodePointerMatch ( const Node< T, _Compare > * p) const

Returns true if all pointers in my data are equal to p. Should be true after a remove operation.

Template Parameters
TThe type of the Skip List Node values.
_CompareA comparison function for type T.
Parameters
pThe Node.
Returns
true if all the Node references are un-swapped (all are referring to the given Node).
486418 {
486419 for (size_t level = height(); level-- > 0;) {
486420 if (p != _nodes[level].pNode) {
486421 return false;
486422 }
486423 }
486424 return true;
Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_back()

template<typename T, typename _Compare>
void duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::push_back ( Node< T, _Compare > * p,
size_t w )
inline

Add a new reference.

486314 {
486315 struct NodeRef<T, _Compare> val = {p, w};
486316 _nodes.push_back(val);

◆ pop_back()

template<typename T, typename _Compare>
void duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::pop_back ( )
inline

Remove top reference.

486320 {
486321 _nodes.pop_back();

◆ swap()

template<typename T, typename _Compare>
void duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::swap ( SwappableNodeRefStack< T, _Compare > & val)

Swap references with another SwappableNodeRefStack at the current swap level. This also increments the swap level.

Template Parameters
TThe type of the Skip List Node values.
_CompareA comparison function for type T.
Parameters
valThe SwappableNodeRefStack.
486436 {
486437 assert(_swapLevel < height());
486441 ++_swapLevel;
size_t _swapLevel
The current swap level.
Definition duckdb.cpp:486348
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetSwapLevel()

template<typename T, typename _Compare>
void duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::resetSwapLevel ( )
inline

Reset the swap level (for example before starting a remove).

◆ incSwapLevel()

template<typename T, typename _Compare>
void duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::incSwapLevel ( )
inline

Increment the swap level. This is used when removing nodes where the parent node can record to what level it has made its adjustments so the grand parent knows where to start.

For this reason the _swapLevel can easily be >= _nodes.size().

Here is the caller graph for this function:

◆ lacksIntegrity()

template<typename T, typename _Compare>
IntegrityCheck duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::lacksIntegrity ( ) const

This checks the internal consistency of the object. It returns INTEGRITY_SUCCESS [0] if successful or non-zero on error. The tests are:

  • Widths must all be >= 1
  • Widths must be weakly increasing with increasing level
Template Parameters
TThe type of the Skip List Node values.
_CompareA comparison function for type T.
Returns
An IntegrityCheck enum.
486457 {
486458 if (height()) {
486459 if (_nodes[0].width != 1) {
486461 }
486462 for (size_t level = 1; level < height(); ++level) {
486463 if (_nodes[level].width < _nodes[level - 1].width) {
486465 }
486466 }
486467 }
486468 return INTEGRITY_SUCCESS;
Here is the call graph for this function:

◆ size_of()

template<typename T, typename _Compare>
size_t duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::size_of ( ) const

Returns an estimate of the memory usage of an instance

Template Parameters
TThe type of the Skip List Node values.
_CompareA comparison function for type T.
Returns
The memory estimate.
486479 {
486480 return sizeof(*this) + _nodes.capacity() * sizeof(struct NodeRef<T>);

◆ clear()

template<typename T, typename _Compare>
void duckdb_skiplistlib::skip_list::SwappableNodeRefStack< T, _Compare >::clear ( )
inline

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