some small changes
This commit is contained in:
parent
bee08e4754
commit
16957ced1a
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "../base/base.h"
|
||||
|
||||
#define __AUTOARR2_MAX_BLOCK_LENGTH_DEFAULT 64
|
||||
#define Autoarr2_NO_REZULT (uint32)-1
|
||||
|
||||
|
||||
@ -32,23 +35,18 @@ public:
|
||||
uint32 search(T& value, cmp_func_lambda cmpf);
|
||||
};
|
||||
|
||||
|
||||
#define __AUTOARR2_MAX_BLOCK_LENGTH_DEFAULT 64
|
||||
|
||||
template<typename T>
|
||||
Autoarr2<T>::Autoarr2() {
|
||||
values=NULL;
|
||||
block_length=0;
|
||||
blocks_count=0;
|
||||
length=0;
|
||||
max_block_length=__AUTOARR2_MAX_BLOCK_LENGTH_DEFAULT;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Autoarr2<T>::Autoarr2(uint16 _max_block_length) : Autoarr2() {
|
||||
Autoarr2<T>::Autoarr2(uint16 _max_block_length) {
|
||||
values = NULL;
|
||||
block_length = 0;
|
||||
blocks_count = 0;
|
||||
length = 0;
|
||||
max_block_length=_max_block_length;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Autoarr2<T>::Autoarr2() : Autoarr2(__AUTOARR2_MAX_BLOCK_LENGTH_DEFAULT) {}
|
||||
|
||||
template<typename T>
|
||||
Autoarr2<T>::~Autoarr2() {
|
||||
for (uint16 i=0;i<blocks_count;i++)
|
||||
|
||||
@ -143,7 +143,8 @@ bool Hashtable2<TKey, TVal>::tryGet(TKey key, TVal* output){
|
||||
}
|
||||
|
||||
template<typename TKey, typename TVal>
|
||||
void Hashtable2<TKey, TVal>::expand(){ printf("expand\n"); fflush(stdout);
|
||||
void Hashtable2<TKey, TVal>::expand(){
|
||||
printf("expand\n"); fflush(stdout);
|
||||
if(hein>=_HT_HEIN_MAX)
|
||||
throw_id(ERR_MAXLENGTH);
|
||||
|
||||
@ -169,7 +170,8 @@ void Hashtable2<TKey, TVal>::expand(){ printf("expand\n"); fflush(stdout);
|
||||
}
|
||||
|
||||
template<typename TKey, typename TVal>
|
||||
void Hashtable2<TKey, TVal>::add(TKey& key, TVal& value, HT_HASH_T keyHash, HT_HEIGHT_T rowN){ printf("add\n"); fflush(stdout);
|
||||
void Hashtable2<TKey, TVal>::add(TKey& key, TVal& value, HT_HASH_T keyHash, HT_HEIGHT_T rowN){
|
||||
printf("add\n"); fflush(stdout);
|
||||
Autoarr2<KeyValue>* row=rows[rowN];
|
||||
if(row->length == _HT_ARR_BC*_HT_ARR_BL)
|
||||
expand();
|
||||
|
||||
@ -54,7 +54,6 @@ char* __unknownErr( );
|
||||
#else
|
||||
#define throw(E) __EXIT(((char*)__genErrMsg((__stringify_err(E)), __FILE__,__LINE__,__func__)))
|
||||
#define safethrow(E, FREEMEM) { FREEMEM; __RETURN_EXCEPTION(((char*)__genErrMsg((__stringify_err(E)), __FILE__,__LINE__,__func__))); }
|
||||
#endif
|
||||
|
||||
#define try(_funcCall, _rezult, freeMem) Maybe _rezult=_funcCall; if(_rezult.errmsg){\
|
||||
freeMem;\
|
||||
@ -66,6 +65,8 @@ char* __unknownErr( );
|
||||
_rezult.errmsg=__extendErrMsg(_rezult.errmsg, __FILE__,__LINE__,__func__);\
|
||||
__EXIT(_rezult.errmsg);\
|
||||
}else
|
||||
|
||||
#endif
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ std::shared_ptr<char> genkey(uint32 i){
|
||||
}
|
||||
|
||||
void fill(HT_TYPE* ht){
|
||||
for(uint32 i=0;i<251;i++)
|
||||
for(uint32 i=0;i<260;i++)
|
||||
ht->add(genkey(i), 555666);
|
||||
print_hashtable(ht);
|
||||
}
|
||||
@ -49,8 +49,8 @@ void test_hashtable2(){
|
||||
[](TKey k) { return hashs(hash_sdbm32,k.get()); });
|
||||
#else
|
||||
HT_TYPE* ht=new HT_TYPE(
|
||||
[](TKey k) { return hashs(hash_sdbm32,k.get()); },
|
||||
[](TKey k0, TKey k1) { return cptr_compare(k0.get(), k1.get()); });
|
||||
[](TKey k) -> HT_HASH_T { return hashs(hash_sdbm32,k.get()); },
|
||||
[](TKey k0, TKey k1) -> bool { return cptr_compare(k0.get(), k1.get()); });
|
||||
#endif
|
||||
printf("\e[92mhashtable created\n");
|
||||
print_hashtable(ht);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user