コード例 #1
0
ファイル: Hash.hpp プロジェクト: denghe/69net
 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;
 }
コード例 #2
0
ファイル: Hash.hpp プロジェクト: denghe/69net
 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;
 }
コード例 #3
0
bool TAbstractEntityMatcher::operator==(const TAbstractEntityMatcher &Other) const noexcept
   {
      return EqualsTo(Other);
   }