diff --git a/src/Autoarr2/Autoarr2.hpp b/src/Autoarr2/Autoarr2.hpp index ad7da69..ede99ed 100644 --- a/src/Autoarr2/Autoarr2.hpp +++ b/src/Autoarr2/Autoarr2.hpp @@ -18,3 +18,67 @@ public: void add(T value); virtual ~Autoarr2(); }; + + +#define __AUTOARR2_MAX_BLOCK_LENGTH_DEFAULT 64 + +template +Autoarr2::Autoarr2() { + values=NULL; + block_length=0; + blocks_count=0; + length=0; + max_block_length=__AUTOARR2_MAX_BLOCK_LENGTH_DEFAULT; +} + +template +Autoarr2::Autoarr2(uint16 _max_block_length) : Autoarr2() { + max_block_length=_max_block_length; +} + +template +T *Autoarr2::getptr(uint32 index) { + if(index>=length) throw_id(ERR_WRONGINDEX); + return values[index/max_block_length]+index%max_block_length; +} + +template +T Autoarr2::get(uint32 index) { + return *getptr(index); +} + +template +void Autoarr2::set(uint32 index, T value) { + *getptr(index)=value; +} + +template +void Autoarr2::add(T value) { + if(!values){ + //values=(T**)malloc(sizeof(T*)); + values=new T*[1]; + goto create_block; + } + else if(block_length==max_block_length){ + block_length=0; +create_block: + T** new_values=new T*[blocks_count+1]; + for(uint32 i=0;i +Autoarr2::~Autoarr2() { + for (uint16 i=0;i; -template class Autoarr2; -template class Autoarr2; -template class Autoarr2; -template class Autoarr2; -template class Autoarr2; -template class Autoarr2; -template class Autoarr2; -template class Autoarr2; -template class Autoarr2; -template class Autoarr2; diff --git a/src/Autoarr2/Autoarr2_methods.hpp b/src/Autoarr2/Autoarr2_methods.hpp deleted file mode 100644 index 9869389..0000000 --- a/src/Autoarr2/Autoarr2_methods.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include "Autoarr2.hpp" - -#define __AUTOARR2_MAX_BLOCK_LENGTH_DEFAULT 64 - -template -Autoarr2::Autoarr2() { - values=NULL; - block_length=0; - blocks_count=0; - length=0; - max_block_length=__AUTOARR2_MAX_BLOCK_LENGTH_DEFAULT; -} - -template -Autoarr2::Autoarr2(uint16 _max_block_length) : Autoarr2() { - max_block_length=_max_block_length; -} - -template -T *Autoarr2::getptr(uint32 index) { - if(index>=length) throw_id(ERR_WRONGINDEX); - return values[index/max_block_length]+index%max_block_length; -} - -template -T Autoarr2::get(uint32 index) { - return *getptr(index); -} - -template -void Autoarr2::set(uint32 index, T value) { - *getptr(index)=value; -} - -template -void Autoarr2::add(T value) { - if(!values){ - //values=(T**)malloc(sizeof(T*)); - values=new T*[1]; - goto create_block; - } - else if(block_length==max_block_length){ - block_length=0; -create_block: - T** new_values=new T*[blocks_count+1]; - for(uint32 i=0;i -Autoarr2::~Autoarr2() { - for (uint16 i=0;i +template class Hashtable2{ uint8 hein; public: Autoarr2* keys; - Autoarr2* values; + Autoarr2* values; Hashtable2(); - TValue get(TKey key); - TValue getptr(TKey key); - bool addOrSet(TKey key, TValue); + TVal get(TKey key); + TVal getptr(TKey key); + bool addOrSet(TKey key, TVal); bool remove(TKey); virtual ~Hashtable2(); }; + + +// amount of rows +static const uint16 HT_HEIGHTS[]={17,61,257,1021,4099,16381,65521}; +#define HT_HEIN_MIN 0 +#define HT_HEIN_MAX 6 + +#define ARR_BC 2 +#define ARR_BL 8 + +template +Hashtable2::Hashtable2() { + hein=HT_HEIN_MIN; + keys=new Autoarr2; + values=new Autoarr2; +} + +template +TVal Hashtable2::get(TKey key) { + +} + +template +TVal Hashtable2::getptr(TKey key) { + +} + +template +bool Hashtable2::addOrSet(TKey key, TVal) { + +} + +template +bool Hashtable2::remove(TKey) { + +} + +template +Hashtable2::~Hashtable2() { + +} diff --git a/src/Hashtable2/Hashtable2_methods.hpp b/src/Hashtable2/Hashtable2_methods.hpp deleted file mode 100644 index 9aa4b92..0000000 --- a/src/Hashtable2/Hashtable2_methods.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "Hashtable2.hpp" - -template -Hashtable2::Hashtable2() { - -} - -template -TValue Hashtable2::get(TKey key) { - -} - -template -TValue Hashtable2::getptr(TKey key) { - -} - -template -bool Hashtable2::addOrSet(TKey key, TValue) { - -} - -template -bool Hashtable2::remove(TKey) { - -} - -template -Hashtable2::~Hashtable2() { - -}