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::UnaryAggregateHeap< T, T_COMPARATOR > Class Template Reference

Public Member Functions

 UnaryAggregateHeap (ArenaAllocator &allocator, idx_t capacity_p)
void Initialize (ArenaAllocator &allocator, const idx_t capacity_p)
bool IsEmpty () const
idx_t Size () const
idx_t Capacity () const
void Insert (ArenaAllocator &allocator, const T &value)
void Insert (ArenaAllocator &allocator, const UnaryAggregateHeap &other)
HeapEntry< T > * SortAndGetHeap ()

Static Public Member Functions

static const T & GetValue (const HeapEntry< T > &slot)

Static Private Member Functions

static bool Compare (const HeapEntry< T > &left, const HeapEntry< T > &right)

Private Attributes

idx_t capacity
HeapEntry< T > * heap
idx_t size

Constructor & Destructor Documentation

◆ UnaryAggregateHeap()

template<class T, class T_COMPARATOR>
duckdb::UnaryAggregateHeap< T, T_COMPARATOR >::UnaryAggregateHeap ( ArenaAllocator & allocator,
idx_t capacity_p )
inline
209873 {
209874 Initialize(allocator, capacity_p);
209875 }
Definition duckdb.cpp:209869

Member Function Documentation

◆ Initialize()

template<class T, class T_COMPARATOR>
void duckdb::UnaryAggregateHeap< T, T_COMPARATOR >::Initialize ( ArenaAllocator & allocator,
const idx_t capacity_p )
inline
209877 {
209878 capacity = capacity_p;
209879 auto ptr = allocator.AllocateAligned(capacity * sizeof(HeapEntry<T>));
209880 memset(ptr, 0, capacity * sizeof(HeapEntry<T>));
209881 heap = reinterpret_cast<HeapEntry<T> *>(ptr);
209882 size = 0;
209883 }

◆ IsEmpty()

template<class T, class T_COMPARATOR>
bool duckdb::UnaryAggregateHeap< T, T_COMPARATOR >::IsEmpty ( ) const
inline
209885 {
209886 return size == 0;
209887 }

◆ Size()

template<class T, class T_COMPARATOR>
idx_t duckdb::UnaryAggregateHeap< T, T_COMPARATOR >::Size ( ) const
inline
209888 {
209889 return size;
209890 }

◆ Capacity()

template<class T, class T_COMPARATOR>
idx_t duckdb::UnaryAggregateHeap< T, T_COMPARATOR >::Capacity ( ) const
inline
209891 {
209892 return capacity;
209893 }

◆ Insert() [1/2]

template<class T, class T_COMPARATOR>
void duckdb::UnaryAggregateHeap< T, T_COMPARATOR >::Insert ( ArenaAllocator & allocator,
const T & value )
inline
209895 {
209896 D_ASSERT(capacity != 0); // must be initialized
209897
209898 // If the heap is not full, insert the value into a new slot
209899 if (size < capacity) {
209900 heap[size++].Assign(allocator, value);
209901 std::push_heap(heap, heap + size, Compare);
209902 }
209903 // If the heap is full, check if the value is greater than the smallest value in the heap
209904 // If it is, assign the new value to the slot and re-heapify
209905 else if (T_COMPARATOR::Operation(value, heap[0].value)) {
209906 std::pop_heap(heap, heap + size, Compare);
209907 heap[size - 1].Assign(allocator, value);
209908 std::push_heap(heap, heap + size, Compare);
209909 }
209910 D_ASSERT(std::is_heap(heap, heap + size, Compare));
209911 }

◆ Insert() [2/2]

template<class T, class T_COMPARATOR>
void duckdb::UnaryAggregateHeap< T, T_COMPARATOR >::Insert ( ArenaAllocator & allocator,
const UnaryAggregateHeap< T, T_COMPARATOR > & other )
inline
209913 {
209914 for (idx_t slot = 0; slot < other.Size(); slot++) {
209915 Insert(allocator, other.heap[slot].value);
209916 }
209917 }

◆ SortAndGetHeap()

template<class T, class T_COMPARATOR>
HeapEntry< T > * duckdb::UnaryAggregateHeap< T, T_COMPARATOR >::SortAndGetHeap ( )
inline
209919 {
209920 std::sort_heap(heap, heap + size, Compare);
209921 return heap;
209922 }

◆ GetValue()

template<class T, class T_COMPARATOR>
const T & duckdb::UnaryAggregateHeap< T, T_COMPARATOR >::GetValue ( const HeapEntry< T > & slot)
inlinestatic
209924 {
209925 return slot.value;
209926 }

◆ Compare()

template<class T, class T_COMPARATOR>
bool duckdb::UnaryAggregateHeap< T, T_COMPARATOR >::Compare ( const HeapEntry< T > & left,
const HeapEntry< T > & right )
inlinestaticprivate
209929 {
209930 return T_COMPARATOR::Operation(left.value, right.value);
209931 }

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