Category : stack-memory

As we know there is multiple ways to declare array in C++. Such as: Static Declaration void createStaticArray() { static int staticArray[SIZE]; } Stack Declaration void createStackArray() { int stackArray[SIZE]; } Heap Declaration void createHeapArray() { int *heapArray = new int[SIZE]; // allocate delete [] heapArray; // deallocate } Furthermore, I’ve written small speed test ..

Read more

Considering when comparer, hasher and allocator are stateless, the struct of rbtree and hashtable should be: template</*…*/> struct RBTree { Node* header; size_t count; [[no_unique_address]] KeyComparer keyComparer; [[no_unique_address]] KeyExtracter keyOf; [[no_unique_address]] NodeAllocator nodeAlloc; }; template</*…*/> struct HashTable { size_t* buckets; Node* items; size_t capacity; size_t count; size_t usedBucketCount; [[no_unique_address]] KeyHasher keyHasher; [[no_unique_address]] KeyExtracter keyOf; [[no_unique_address]] ..

Read more