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_re2::SparseSetT< Value > Class Template Reference
Collaboration diagram for duckdb_re2::SparseSetT< Value >:

Public Types

typedef int * iterator
typedef const int * const_iterator

Public Member Functions

 SparseSetT (int max_size)
int size () const
int empty () const
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
void resize (int new_max_size)
int max_size () const
void clear ()
bool contains (int i) const
iterator insert (int i)
iterator insert_new (int i)

Static Public Member Functions

static bool less (int a, int b)

Private Member Functions

iterator InsertInternal (bool allow_existing, int i)
void create_index (int i)
void DebugCheckInvariants () const
void MaybeInitializeMemory (int min, int max)

Private Attributes

int size_ = 0
PODArray< int > sparse_
PODArray< int > dense_

Constructor & Destructor Documentation

◆ SparseSetT()

template<typename Value>
duckdb_re2::SparseSetT< Value >::SparseSetT ( int max_size)
explicit
459764 :
459765 sparse_(max_size), dense_(max_size) {
459766 MaybeInitializeMemory(size_, max_size);
459767 DebugCheckInvariants();
459768}

◆ ~SparseSetT()

template<typename Value>
duckdb_re2::SparseSetT< Value >::~SparseSetT ( )
459770 {
459771 DebugCheckInvariants();
459772}

Member Function Documentation

◆ size()

template<typename Value>
int duckdb_re2::SparseSetT< Value >::size ( ) const
inline
459603 {
459604 return size_;
459605 }

◆ empty()

template<typename Value>
int duckdb_re2::SparseSetT< Value >::empty ( ) const
inline
459608 {
459609 return size_ == 0;
459610 }

◆ begin() [1/2]

template<typename Value>
iterator duckdb_re2::SparseSetT< Value >::begin ( )
inline
459613 {
459614 return dense_.data();
459615 }

◆ end() [1/2]

template<typename Value>
iterator duckdb_re2::SparseSetT< Value >::end ( )
inline
459616 {
459617 return dense_.data() + size_;
459618 }

◆ begin() [2/2]

template<typename Value>
const_iterator duckdb_re2::SparseSetT< Value >::begin ( ) const
inline
459620 {
459621 return dense_.data();
459622 }

◆ end() [2/2]

template<typename Value>
const_iterator duckdb_re2::SparseSetT< Value >::end ( ) const
inline
459623 {
459624 return dense_.data() + size_;
459625 }

◆ resize()

template<typename Value>
void duckdb_re2::SparseSetT< Value >::resize ( int new_max_size)
459720 {
459721 DebugCheckInvariants();
459722 if (new_max_size > max_size()) {
459723 const int old_max_size = max_size();
459724
459725 // Construct these first for exception safety.
459728
459729 std::copy_n(sparse_.data(), old_max_size, a.data());
459730 std::copy_n(dense_.data(), old_max_size, b.data());
459731
459732 sparse_ = std::move(a);
459733 dense_ = std::move(b);
459734
459735 MaybeInitializeMemory(old_max_size, new_max_size);
459736 }
459737 if (size_ > new_max_size)
459738 size_ = new_max_size;
459739 DebugCheckInvariants();
459740}
Definition duckdb.cpp:459593

◆ max_size()

template<typename Value>
int duckdb_re2::SparseSetT< Value >::max_size ( ) const
inline
459633 {
459634 if (dense_.data() != NULL)
459635 return dense_.size();
459636 else
459637 return 0;
459638 }

◆ clear()

template<typename Value>
void duckdb_re2::SparseSetT< Value >::clear ( )
inline
459641 {
459642 size_ = 0;
459643 }

◆ contains()

template<typename Value>
bool duckdb_re2::SparseSetT< Value >::contains ( int i) const
459744 {
459745 assert(i >= 0);
459746 assert(i < max_size());
459747 if (static_cast<uint32_t>(i) >= static_cast<uint32_t>(max_size())) {
459748 return false;
459749 }
459750 // Unsigned comparison avoids checking sparse_[i] < 0.
459751 return (uint32_t)sparse_[i] < (uint32_t)size_ &&
459752 dense_[sparse_[i]] == i;
459753}
#define assert(x)
Definition duckdb.cpp:486071

◆ less()

template<typename Value>
bool duckdb_re2::SparseSetT< Value >::less ( int a,
int b )
static
459780 {
459781 return a < b;
459782}

◆ insert()

template<typename Value>
iterator duckdb_re2::SparseSetT< Value >::insert ( int i)
inline
459656 {
459657 return InsertInternal(true, i);
459658 }

◆ insert_new()

template<typename Value>
iterator duckdb_re2::SparseSetT< Value >::insert_new ( int i)
inline
459662 {
459663 return InsertInternal(false, i);
459664 }

◆ InsertInternal()

template<typename Value>
iterator duckdb_re2::SparseSetT< Value >::InsertInternal ( bool allow_existing,
int i )
inlineprivate
459667 {
459668 DebugCheckInvariants();
459669 if (static_cast<uint32_t>(i) >= static_cast<uint32_t>(max_size())) {
459670 assert(false && "illegal index");
459671 // Semantically, end() would be better here, but we already know
459672 // the user did something stupid, so begin() insulates them from
459673 // dereferencing an invalid pointer.
459674 return begin();
459675 }
459676 if (!allow_existing) {
459677 assert(!contains(i));
459678 create_index(i);
459679 } else {
459680 if (!contains(i))
459681 create_index(i);
459682 }
459683 DebugCheckInvariants();
459684 return dense_.data() + sparse_[i];
459685 }

◆ create_index()

template<typename Value>
void duckdb_re2::SparseSetT< Value >::create_index ( int i)
private
459756 {
459757 assert(!contains(i));
459758 assert(size_ < max_size());
459759 sparse_[i] = size_;
459760 dense_[size_] = i;
459761 size_++;
459762}

◆ DebugCheckInvariants()

template<typename Value>
void duckdb_re2::SparseSetT< Value >::DebugCheckInvariants ( ) const
private
459774 {
459775 assert(0 <= size_);
459776 assert(size_ <= max_size());
459777}

◆ MaybeInitializeMemory()

template<typename Value>
void duckdb_re2::SparseSetT< Value >::MaybeInitializeMemory ( int min,
int max )
inlineprivate
459699 {
459700#if __has_feature(memory_sanitizer)
459701 __msan_unpoison(sparse_.data() + min, (max - min) * sizeof sparse_[0]);
459702#elif defined(RE2_ON_VALGRIND)
459703 for (int i = min; i < max; i++) {
459704 sparse_[i] = 0xababababU;
459705 }
459706#endif
459707 }

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