From bb555e34e3673391685b7c5e7d55482ead126089 Mon Sep 17 00:00:00 2001 From: epochryphon Date: Tue, 26 May 2026 00:06:31 -0500 Subject: [PATCH] added first few actual implementaitons --- .../MODULE_marigold_vector/marigold_vector.c | 337 ++++++++++++++++++ 1 file changed, 337 insertions(+) diff --git a/source_code/MODULE_marigold_vector/marigold_vector.c b/source_code/MODULE_marigold_vector/marigold_vector.c index e69de29..3c0bf40 100644 --- a/source_code/MODULE_marigold_vector/marigold_vector.c +++ b/source_code/MODULE_marigold_vector/marigold_vector.c @@ -0,0 +1,337 @@ +#include "marigold_vector.h" + +#include + +vector_struct* +vector_create(size_t item_size, + size_t starting_capacity, + vector_growth_rate_enum growth_rate, + int (*comparator)(const void*, const void*), + void (*item_free)(const void *), + bool is_multithread_safe) +{ + // allocate memory/mutex etc + return vector_initialize(); // actually set all internal values accordingly. +} + +bool +vector_destroy(vector_struct* vector_to_destroy) +{ + bool destroyed_successfully = false; + vector_free_members(); // actually frees all internal stuff + // then free the base container/mutex etc. + return destroyed_successfully; +} + +void +vector_set_flag(vector_struct* vector, + vector_flag_enum flag, + bool value) +{ + if (value) + { + vector->flags |= flag; // Bitwise or with value. + } + else + { + vector->flags &= ~flag; // Bitwise and with inverted value. + } +} + +bool +vector_get_flag_value(const vector_struct* vector, + vector_flag_enum flag) +{ + if ((vector->flags & flag) != 0) // Checks if the existing bit is equal to 1. + { + return true; + } + else + { + return false; + } +} + +size_t +vector_get_occupancy(const vector_struct* vector) +{ + return vector->current_occupancy; +} + +size_t +vector_get_capacity(const vector_struct* vector) +{ + return vector->current_capacity; +} + +void* +vector_get_pointer_to_index(vector_struct* vector, + size_t index) +{ + return (char*)vector->data_pointer + (index * vector->item_size); +} + +const void* +vector_get_const_pointer_to_index(const vector_struct* vector, + size_t index) +{ + return (const char*)vector->data_pointer + (index * vector->item_size); +} + +void* +vector_get_raw_data_pointer(const vector_struct* vector) +{ + return vector->data_pointer; +} + +bool +vector_append(vector_struct* vector, const void* element) +{ + +} + +bool +vector_insert_at(vector_struct* vector, + size_t index, + const void* element) +{ + +} + +bool +vector_set_item(vector_struct* vector, + size_t index, + const void* new_element) +{ + +} + +bool +vector_swap(vector_struct* vector, + size_t index_a, + size_t index_b) +{ + +} + +bool +vector_pop(vector_struct* vector) +{ + +} + +bool +vector_remove(vector_struct* vector, + size_t index) +{ + +} + +void +vector_clear(vector_struct* vector) +{ + +} + +bool +vector_is_empty(const vector_struct* vector) +{ + if (vector->current_occupancy == 0) + { + return true; + } + else + { + return false; + } +} + +bool +vector_increase_capacity(vector_struct* vector, + size_t new_capacity) +{ + +} + +bool +vector_shrink_to_fit(vector_struct* vector) +{ + +} + +bool +vector_acquire(vector_struct* vector) +{ + +} + +bool +vector_release(vector_struct* vector) +{ + +} + +unsigned short +vector_get_owner_count(const vector_struct* vector) +{ + return vector->owner_count; +} + +bool +vector_is_thread_safe(const vector_struct* vector) +{ + if ((vector->flags & vector_multithread_safe) != 0) + { + return true; + } + else + { + return false; + } +} + +vector_struct* +vector_shallow_copy(const vector_struct* vector_to_copy) +{ + +} + +vector_struct* +vector_deep_copy(const vector_struct* vector_to_copy, + void* (*item_copy)(const void* item)) +{ + +} + +vector_struct* +vector_shallow_copy_slice(const vector_struct* vector_to_copy, + size_t starting_point, + size_t ending_point, + bool is_start_inclusive, + bool is_end_inclusive) +{ + +} + +vector_struct* +vector_deep_copy_slice(const vector_struct* vector_to_copy, + void* (*item_copy)(const void* item), + size_t starting_point, + size_t ending_point, + bool is_start_inclusive, + bool is_end_inclusive) +{ + +} + +void +vector_sort_in_place(vector_struct* vector_to_sort, + bool should_reverse_sort) +{ + +} + +void +vector_sort_slice(vector_struct* vector_to_sort, + size_t starting_point, + size_t ending_point, + bool is_start_inclusive, + bool is_end_inclusive, + bool should_reverse_sort) +{ + +} + +vector_struct* +vector_get_sorted_copy(const vector_struct* vector, + bool should_reverse_sort) +{ + +} + +void +vector_reverse(vector_struct* vector_to_reverse) +{ + +} + +bool +vector_contains(const vector_struct* vector_to_search, + const void* pointer_of_value_to_find) +{ + +} + +size_t +vector_find_first_index_of(const vector_struct* vector_to_search, + const void* pointer_of_value_to_find) +{ + +} + +size_t +vector_find_final_index_of(const vector_struct* vector_to_search, + const void* pointer_of_value_to_find) +{ + +} + +void +vector_set_comparator_function(vector_struct *vector, + int (*comparator)(const void*, const void*)) +{ + vector->comparator = comparator; +} + +bool +vector_get_item(const vector_struct* vector, + size_t index, + void* out_buffer) +{ + +} + +void +vector_iterate_over(vector_struct* vector, + void (*callback)(void* element, void* user_data), + size_t starting_index, + size_t ending_index, + bool is_start_inclusive, + bool is_end_inclusive) +{ + +} + +void +vector_foreach(vector_struct* vector, + void (*callback)(void* element, void* user_data)) +{ + +} + +size_t +vector_binary_search(const vector_struct* vector, + const void* value) +{ + +} + +#ifdef MARIGOLD_DEBUG +void +vector_debug_print_stats(const vector_struct* vector) +{ + +} + +void +vector_debug_dump_vector(const vector_struct* vector) +{ + +} + +bool +vector_validate_integrity(const vector_struct* vector) +{ + +} +#endif /* MARIGOLD_DEBUG */