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

Classes

class  IndexValue

Public Types

typedef IndexValue * iterator
typedef const IndexValue * const_iterator

Public Member Functions

 SparseArray (int max_size)
 SparseArray (const SparseArray &src)
 SparseArray (SparseArray &&src)
SparseArray & operator= (const SparseArray &src)
SparseArray & operator= (SparseArray &&src)
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 has_index (int i) const
iterator set (int i, const Value &v)
iterator set_new (int i, const Value &v)
iterator set_existing (int i, const Value &v)
Value & get_existing (int i)
const Value & get_existing (int i) const

Static Public Member Functions

static bool less (const IndexValue &a, const IndexValue &b)

Private Member Functions

iterator SetInternal (bool allow_existing, int i, const Value &v)
iterator SetExistingInternal (int i, const Value &v)
void create_index (int i)
void DebugCheckInvariants () const
void MaybeInitializeMemory (int min, int max)

Private Attributes

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

Constructor & Destructor Documentation

◆ SparseArray() [1/3]

template<typename Value>
duckdb_re2::SparseArray< Value >::SparseArray ( int max_size)
explicit
459491 :
459492 sparse_(max_size), dense_(max_size) {
459493 MaybeInitializeMemory(size_, max_size);
459494 DebugCheckInvariants();
459495}

◆ ~SparseArray()

template<typename Value>
duckdb_re2::SparseArray< Value >::~SparseArray ( )
459497 {
459498 DebugCheckInvariants();
459499}

◆ SparseArray() [2/3]

template<typename Value>
duckdb_re2::SparseArray< Value >::SparseArray ( const SparseArray< Value > & src)
459392 : size_(src.size_),
459393 sparse_(src.max_size()),
459394 dense_(src.max_size()) {
459395 std::copy_n(src.sparse_.data(), src.max_size(), sparse_.data());
459396 std::copy_n(src.dense_.data(), src.max_size(), dense_.data());
459397}
Definition duckdb.cpp:459232

◆ SparseArray() [3/3]

template<typename Value>
duckdb_re2::SparseArray< Value >::SparseArray ( SparseArray< Value > && src)
459401 : size_(src.size_),
459402 sparse_(std::move(src.sparse_)),
459403 dense_(std::move(src.dense_)) {
459404 src.size_ = 0;
459405}

Member Function Documentation

◆ operator=() [1/2]

template<typename Value>
SparseArray< Value > & duckdb_re2::SparseArray< Value >::operator= ( const SparseArray< Value > & src)
459408 {
459409 // Construct these first for exception safety.
459410 PODArray<int> a(src.max_size());
459411 PODArray<IndexValue> b(src.max_size());
459412
459413 size_ = src.size_;
459414 sparse_ = std::move(a);
459415 dense_ = std::move(b);
459416 std::copy_n(src.sparse_.data(), src.max_size(), sparse_.data());
459417 std::copy_n(src.dense_.data(), src.max_size(), dense_.data());
459418 return *this;
459419}

◆ operator=() [2/2]

template<typename Value>
SparseArray< Value > & duckdb_re2::SparseArray< Value >::operator= ( SparseArray< Value > && src)
459422 {
459423 size_ = src.size_;
459424 sparse_ = std::move(src.sparse_);
459425 dense_ = std::move(src.dense_);
459426 src.size_ = 0;
459427 return *this;
459428}

◆ size()

template<typename Value>
int duckdb_re2::SparseArray< Value >::size ( ) const
inline
459251 {
459252 return size_;
459253 }

◆ empty()

template<typename Value>
int duckdb_re2::SparseArray< Value >::empty ( ) const
inline
459256 {
459257 return size_ == 0;
459258 }

◆ begin() [1/2]

template<typename Value>
iterator duckdb_re2::SparseArray< Value >::begin ( )
inline
459261 {
459262 return dense_.data();
459263 }

◆ end() [1/2]

template<typename Value>
iterator duckdb_re2::SparseArray< Value >::end ( )
inline
459264 {
459265 return dense_.data() + size_;
459266 }

◆ begin() [2/2]

template<typename Value>
const_iterator duckdb_re2::SparseArray< Value >::begin ( ) const
inline
459268 {
459269 return dense_.data();
459270 }

◆ end() [2/2]

template<typename Value>
const_iterator duckdb_re2::SparseArray< Value >::end ( ) const
inline
459271 {
459272 return dense_.data() + size_;
459273 }

◆ resize()

template<typename Value>
void duckdb_re2::SparseArray< Value >::resize ( int new_max_size)
459447 {
459448 DebugCheckInvariants();
459449 if (new_max_size > max_size()) {
459450 const int old_max_size = max_size();
459451
459452 // Construct these first for exception safety.
459455
459456 std::copy_n(sparse_.data(), old_max_size, a.data());
459457 std::copy_n(dense_.data(), old_max_size, b.data());
459458
459459 sparse_ = std::move(a);
459460 dense_ = std::move(b);
459461
459462 MaybeInitializeMemory(old_max_size, new_max_size);
459463 }
459464 if (size_ > new_max_size)
459465 size_ = new_max_size;
459466 DebugCheckInvariants();
459467}

◆ max_size()

template<typename Value>
int duckdb_re2::SparseArray< Value >::max_size ( ) const
inline
459281 {
459282 if (dense_.data() != NULL)
459283 return dense_.size();
459284 else
459285 return 0;
459286 }

◆ clear()

template<typename Value>
void duckdb_re2::SparseArray< Value >::clear ( )
inline
459289 {
459290 size_ = 0;
459291 }

◆ has_index()

template<typename Value>
bool duckdb_re2::SparseArray< Value >::has_index ( int i) const
459471 {
459472 assert(i >= 0);
459473 assert(i < max_size());
459474 if (static_cast<uint32_t>(i) >= static_cast<uint32_t>(max_size())) {
459475 return false;
459476 }
459477 // Unsigned comparison avoids checking sparse_[i] < 0.
459478 return (uint32_t)sparse_[i] < (uint32_t)size_ &&
459479 dense_[sparse_[i]].index_ == i;
459480}
#define assert(x)
Definition duckdb.cpp:486071

◆ less()

template<typename Value>
bool duckdb_re2::SparseArray< Value >::less ( const IndexValue & a,
const IndexValue & b )
static
459508 {
459509 return a.index_ < b.index_;
459510}

◆ set()

template<typename Value>
iterator duckdb_re2::SparseArray< Value >::set ( int i,
const Value & v )
inline
459304 {
459305 return SetInternal(true, i, v);
459306 }

◆ set_new()

template<typename Value>
iterator duckdb_re2::SparseArray< Value >::set_new ( int i,
const Value & v )
inline
459310 {
459311 return SetInternal(false, i, v);
459312 }

◆ set_existing()

template<typename Value>
iterator duckdb_re2::SparseArray< Value >::set_existing ( int i,
const Value & v )
inline
459316 {
459317 return SetExistingInternal(i, v);
459318 }

◆ get_existing() [1/2]

template<typename Value>
Value & duckdb_re2::SparseArray< Value >::get_existing ( int i)
inline
459322 {
459323 assert(has_index(i));
459324 return dense_[sparse_[i]].value_;
459325 }

◆ get_existing() [2/2]

template<typename Value>
const Value & duckdb_re2::SparseArray< Value >::get_existing ( int i) const
inline
459326 {
459327 assert(has_index(i));
459328 return dense_[sparse_[i]].value_;
459329 }

◆ SetInternal()

template<typename Value>
iterator duckdb_re2::SparseArray< Value >::SetInternal ( bool allow_existing,
int i,
const Value & v )
inlineprivate
459332 {
459333 DebugCheckInvariants();
459334 if (static_cast<uint32_t>(i) >= static_cast<uint32_t>(max_size())) {
459335 assert(false && "illegal index");
459336 // Semantically, end() would be better here, but we already know
459337 // the user did something stupid, so begin() insulates them from
459338 // dereferencing an invalid pointer.
459339 return begin();
459340 }
459341 if (!allow_existing) {
459342 assert(!has_index(i));
459343 create_index(i);
459344 } else {
459345 if (!has_index(i))
459346 create_index(i);
459347 }
459348 return SetExistingInternal(i, v);
459349 }

◆ SetExistingInternal()

template<typename Value>
iterator duckdb_re2::SparseArray< Value >::SetExistingInternal ( int i,
const Value & v )
inlineprivate
459351 {
459352 DebugCheckInvariants();
459353 assert(has_index(i));
459354 dense_[sparse_[i]].value_ = v;
459355 DebugCheckInvariants();
459356 return dense_.data() + sparse_[i];
459357 }

◆ create_index()

template<typename Value>
void duckdb_re2::SparseArray< Value >::create_index ( int i)
private
459483 {
459484 assert(!has_index(i));
459485 assert(size_ < max_size());
459486 sparse_[i] = size_;
459487 dense_[size_].index_ = i;
459488 size_++;
459489}

◆ DebugCheckInvariants()

template<typename Value>
void duckdb_re2::SparseArray< Value >::DebugCheckInvariants ( ) const
private
459501 {
459502 assert(0 <= size_);
459503 assert(size_ <= max_size());
459504}

◆ MaybeInitializeMemory()

template<typename Value>
void duckdb_re2::SparseArray< Value >::MaybeInitializeMemory ( int min,
int max )
inlineprivate
459372 {
459373#if __has_feature(memory_sanitizer)
459374 __msan_unpoison(sparse_.data() + min, (max - min) * sizeof sparse_[0]);
459375#elif defined(RE2_ON_VALGRIND)
459376 for (int i = min; i < max; i++) {
459377 sparse_[i] = 0xababababU;
459378 }
459379#endif
459380 }

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