Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions inkcpp/avl_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ class avl_array
// 'node' structure
ink::runtime::internal::if_t<dynamic, Key*, Key[Size]> key_;
ink::runtime::internal::if_t<dynamic, T*, T[Size]> val_;
ink::runtime::internal::if_t<dynamic, char*, char[Size]> balance_;
ink::runtime::internal::if_t<dynamic, child_type*, child_type[Size]> child_;
size_type size_; // actual size
size_type _capacity;
size_type root_; // root node
ink::runtime::internal::if_t<dynamic, size_type*, size_type[Fast ? Size : 1]> parent_;

using balance_type = signed char;
ink::runtime::internal::if_t<dynamic, balance_type*, balance_type[Size]> balance_;

// invalid index (like 'nullptr' in a pointer implementation)
static const size_type INVALID_IDX = ~static_cast<size_type>(0);

Expand Down Expand Up @@ -197,7 +199,7 @@ class avl_array
if constexpr (dynamic) {
key_ = new Key[Size];
val_ = new T[Size];
balance_ = new char[Size];
balance_ = new balance_type[Size];
child_ = new child_type[Size];
if constexpr (Fast) {
parent_ = new size_type[Size];
Expand Down Expand Up @@ -285,7 +287,7 @@ class avl_array
val_ = new_data;
}
{
char* new_data = new char[new_size];
balance_type* new_data = new balance_type[new_size];
for (size_type i = 0; i < _capacity; ++i) {
new_data[i] = balance_[i];
}
Expand Down Expand Up @@ -660,7 +662,7 @@ class avl_array
set_parent(target, get_parent(source));
}

void insert_balance(size_type node, char balance)
void insert_balance(size_type node, balance_type balance)
{
while (node != INVALID_IDX) {
balance = (balance_[node] += balance);
Expand Down Expand Up @@ -691,7 +693,7 @@ class avl_array
}
}

void delete_balance(size_type node, char balance)
void delete_balance(size_type node, balance_type balance)
{
while (node != INVALID_IDX) {
balance = (balance_[node] += balance);
Expand Down
Loading