std::pair<typename Hash<TK>::Node*, bool> Hash<TK>::Insert( TK const& k ) { std::pair<typename Hash<TK>::Node*, bool> rtv; uint hashCode = (uint)GetHashCode( k ); uint mod = hashCode % (uint)buckets.Size(); auto node = buckets[ mod ]; while( node ) { if( node->hash == hashCode && EqualsTo( node->key, k ) ) { rtv.first = node; rtv.second = false; return rtv; } node = node->next; }; auto n = (Node*)pool.Alloc(); n->next = buckets[ mod ]; n->hash = hashCode; n->index = nodes.Size(); new ( &n->key ) TK( k ); buckets[ mod ] = n; nodes.Push( n ); if( nodes.Size() == buckets.Size() ) Resize(); rtv.first = n; rtv.second = true; return rtv; }
typename Hash<TK>::Node* Hash<TK>::Find( TK const& k ) { uint hashCode = (uint)GetHashCode( k ); uint mod = hashCode % (uint)buckets.Size(); auto node = buckets[ mod ]; while( node ) { if( node->hash == hashCode && EqualsTo( node->key, k ) ) return node; node = node->next; } return nullptr; }
bool TAbstractEntityMatcher::operator==(const TAbstractEntityMatcher &Other) const noexcept { return EqualsTo(Other); }