13 #define hashptr(p) ((SQHash)(((SQInteger)p) >> 3)) 17 switch(sq_type(key)) {
18 case OT_STRING:
return _string(key)->_hash;
19 case OT_FLOAT:
return (SQHash)((SQInteger)_float(key));
20 case OT_BOOL:
case OT_INTEGER:
return (SQHash)((SQInteger)_integer(key));
21 default:
return hashptr(key._unVal.pRefCounted);
30 _HashNode() { next = NULL; }
35 _HashNode *_firstfree;
37 SQInteger _numofnodes;
41 void AllocNodes(SQInteger nSize);
42 void Rehash(
bool force);
49 new (newtable)
SQTable(ss, nInitialSize);
50 newtable->_delegate = NULL;
58 REMOVE_FROM_CHAIN(&_sharedstate->_gc_chain,
this);
59 for (SQInteger i = 0; i < _numofnodes; i++) _nodes[i].~_HashNode();
60 SQ_FREE(_nodes, _numofnodes *
sizeof(_HashNode));
62 #ifndef NO_GARBAGE_COLLECTOR 64 SQObjectType GetType() {
return OT_TABLE;}
66 inline _HashNode *_Get(
const SQObjectPtr &key,SQHash hash)
68 _HashNode *n = &_nodes[hash];
70 if(_rawval(n->key) == _rawval(key) && sq_type(n->key) == sq_type(key)){
73 }
while((n = n->next));
77 inline bool GetStr(
const SQChar* key,SQInteger keylen,
SQObjectPtr &val)
79 SQHash hash = _hashstr(key,keylen);
80 _HashNode *n = &_nodes[hash & (_numofnodes - 1)];
81 _HashNode *res = NULL;
83 if(sq_type(n->key) == OT_STRING && (scstrcmp(_stringval(n->key),key) == 0)){
87 }
while((n = n->next));
89 val = _realval(res->val);
101 SQInteger CountUsed(){
return _usednodes;}
Definition: sqobject.h:339
Definition: sqobject.h:205
Definition: sqobject.h:313