Logo Search packages:      
Sourcecode: scummvm version File versions  Download package

template<class Key, class Val, class HashFunc, class EqualFunc>
void Common::HashMap< Key, Val, HashFunc, EqualFunc >::assign ( const HM_t map  )  [inline, private]

Internal method for assigning the content of another HashMap to this one.

Note:
We do *not* deallocate the previous storage here -- the caller is responsible for doing that!

Definition at line 347 of file hashmap.h.

References Common::HashMap< Key, Val, HashFunc, EqualFunc >::_deleted, Common::HashMap< Key, Val, HashFunc, EqualFunc >::_mask, Common::HashMap< Key, Val, HashFunc, EqualFunc >::_size, and Common::HashMap< Key, Val, HashFunc, EqualFunc >::_storage.

Referenced by Common::HashMap< Key, Val, HashFunc, EqualFunc >::HashMap().

                                                                   {
      _mask = map._mask;
      _storage = new Node *[_mask+1];
      assert(_storage != NULL);
      memset(_storage, 0, (_mask+1) * sizeof(Node *));

      // Simply clone the map given to us, one by one.
      _size = 0;
      _deleted = 0;
      for (uint ctr = 0; ctr <= _mask; ++ctr) {
            if (map._storage[ctr] == HASHMAP_DUMMY_NODE) {
                  _storage[ctr] = HASHMAP_DUMMY_NODE;
                  _deleted++;
            } else if (map._storage[ctr] != NULL) {
                  _storage[ctr] = allocNode(map._storage[ctr]->_key);
                  _storage[ctr]->_value = map._storage[ctr]->_value;
                  _size++;
            }
      }
      // Perform a sanity check (to help track down hashmap corruption)
      assert(_size == map._size);
      assert(_deleted == map._deleted);
}


Generated by  Doxygen 1.6.0   Back to index