some small additions
This commit is contained in:
+21
-1
@@ -114,7 +114,6 @@ struct Array_List {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void dealloc() {
|
void dealloc() {
|
||||||
free(data);
|
free(data);
|
||||||
data = nullptr;
|
data = nullptr;
|
||||||
@@ -124,6 +123,19 @@ struct Array_List {
|
|||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool contains_linear_search(type elem) {
|
||||||
|
for (u32 i = 0; i < count; ++i) {
|
||||||
|
if (data[i] == elem)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool contains_binary_search(type elem) {
|
||||||
|
return sorted_find(elem) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Array_List<type> clone() {
|
Array_List<type> clone() {
|
||||||
Array_List<type> ret;
|
Array_List<type> ret;
|
||||||
ret.length = length;
|
ret.length = length;
|
||||||
@@ -309,6 +321,14 @@ struct Queue {
|
|||||||
return arr_list.count - next_index;
|
return arr_list.count - next_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool contains(type elem) {
|
||||||
|
for (u32 i = next_index; i < arr_list.count; ++i) {
|
||||||
|
if (arr_list[i] == elem)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
next_index = 0;
|
next_index = 0;
|
||||||
arr_list.clear();
|
arr_list.clear();
|
||||||
|
|||||||
@@ -82,6 +82,12 @@ struct Hash_Map {
|
|||||||
data = nullptr;
|
data = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
cell_count = 0;
|
||||||
|
memset(data, 0, current_capacity * sizeof(HM_Cell));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
s32 get_index_of_living_cell_if_it_exists(key_type key, u64 hash_val) {
|
s32 get_index_of_living_cell_if_it_exists(key_type key, u64 hash_val) {
|
||||||
s32 index = hash_val & (current_capacity - 1);
|
s32 index = hash_val & (current_capacity - 1);
|
||||||
HM_Cell cell = data[index];
|
HM_Cell cell = data[index];
|
||||||
|
|||||||
Reference in New Issue
Block a user