File:
HashMap .d

Originally written by Doug Lea and released into the public domain. Thanks for the assistance and support of Sun Microsystems Labs, Agorics Inc, Loral, and everyone contributing, testing, and using this code.

History:
Date Who What 24Sep95 dl@cs.oswego.edu Create from collection.d working file 13Oct95 dl Changed protection statuses 21Oct95 dl fixed error in removeAt 9Apr97 dl made Serializable 14Dec06 kb Converted, templated & reshaped for Tango

  • class HashMap (K,V): MapCollection!(K,V), HashParams;
  • Hash table implementation of Map

    author:
    Doug Lea @version 0.94

    For an introduction to this package see Overview .

  • LLPairT[] table ;
  • The table . Each entry is a list. Null if no table allocated

  • float loadFactor ;
  • The threshold load factor

  • this(Predicate screener = null);
  • Make a new empty map to use given element screener.

  • this(Predicate s, float f);
  • Special version of constructor needed by clone()

  • HashMap!(K,V) duplicate ();
  • Make an independent copy of the table. Elements themselves are not cloned.

  • int buckets ();
  • Implements tango.util.collection.HashParams. buckets . Time complexity: O(1).

    See Also:
    tango.util.collection.HashParams. buckets .



  • void buckets (int newCap);
  • Implements tango.util.collection.HashParams. buckets . Time complexity: O(n).

    See Also:
    tango.util.collection.HashParams. buckets .



  • float thresholdLoadFactor ();
  • Implements tango.util.collection.HashParams.thresholdLoadfactor Time complexity: O(1).

    See Also:
    tango.util.collection.HashParams.thresholdLoadfactor



  • void thresholdLoadFactor (float desired);
  • Implements tango.util.collection.HashParams.thresholdLoadfactor Time complexity: O(n).

    See Also:
    tango.util.collection.HashParams.thresholdLoadfactor



  • bool contains (V element);
  • Implements tango.util.collection.model.View.View. contains . Time complexity: O(1) average; O(n) worst.

    See Also:
    tango.util.collection.model.View.View. contains



  • uint instances (V element);
  • Implements tango.util.collection.model.View.View. instances . Time complexity: O(n).

    See Also:
    tango.util.collection.model.View.View. instances



  • GuardIterator!(V) elements ();
  • Implements tango.util.collection.model.View.View. elements . Time complexity: O(1).

    See Also:
    tango.util.collection.model.View.View. elements



  • int opApply (int delegate(ref V value) dg);
  • Implements tango.util.collection.model.View.View. opApply Time complexity: O(n)

    See Also:
    tango.util.collection.model.View.View. opApply



  • int opApply (int delegate(ref K key, ref V value) dg);
  • Implements tango.util.collection.MapView. opApply Time complexity: O(n)

    See Also:
    tango.util.collection.MapView. opApply



  • bool containsKey (K key);
  • Implements tango.util.collection.Map. containsKey . Time complexity: O(1) average; O(n) worst.

    See Also:
    tango.util.collection.Map. containsKey



  • bool containsPair (K key, V element);
  • Implements tango.util.collection.Map. containsPair Time complexity: O(1) average; O(n) worst.

    See Also:
    tango.util.collection.Map. containsPair



  • PairIterator!(K,V) keys ();
  • Implements tango.util.collection.Map. keys . Time complexity: O(1).

    See Also:
    tango.util.collection.Map. keys



  • V get (K key);
  • Implements tango.util.collection.Map. get . Time complexity: O(1) average; O(n) worst.

    See Also:
    tango.util.collection.Map.at



  • bool get (K key, ref V element);
  • Return the element associated with Key key. @param key a key

    Returns:
    whether the key is contained or not



  • bool keyOf (ref K key, V value);
  • Implements tango.util.collection.Map. keyOf . Time complexity: O(n).

    See Also:
    tango.util.collection.Map.akyOf



  • void clear ();
  • Implements tango.util.collection.impl.Collection.Collection. clear . Time complexity: O(1).

    See Also:
    tango.util.collection.impl.Collection.Collection. clear



  • void removeAll (V element);
  • Implements tango.util.collection.impl.Collection.Collection. removeAll . Time complexity: O(n).

    See Also:
    tango.util.collection.impl.Collection.Collection. removeAll



  • void remove (V element);
  • Implements tango.util.collection.impl.Collection.Collection.removeOneOf. Time complexity: O(n).

    See Also:
    tango.util.collection.impl.Collection.Collection.removeOneOf



  • void replace (V oldElement, V newElement);
  • Implements tango.util.collection.impl.Collection.Collection.replaceOneOf. Time complexity: O(n).

    See Also:
    tango.util.collection.impl.Collection.Collection.replaceOneOf



  • void replaceAll (V oldElement, V newElement);
  • Implements tango.util.collection.impl.Collection.Collection.replaceOneOf. Time complexity: O(n).

    See Also:
    tango.util.collection.impl.Collection.Collection.replaceOneOf



  • V take ();
  • Implements tango.util.collection.impl.Collection.Collection. take . Time complexity: O(number of buckets).

    See Also:
    tango.util.collection.impl.Collection.Collection. take



  • void add (K key, V element);
  • Implements tango.util.collection.Map. add . Time complexity: O(1) average; O(n) worst.

    See Also:
    tango.util.collection.Map. add



  • void removeKey (K key);
  • Implements tango.util.collection.Map.remove. Time complexity: O(1) average; O(n) worst.

    See Also:
    tango.util.collection.Map.remove



  • void replacePair (K key, V oldElement, V newElement);
  • Implements tango.util.collection.Map.replaceElement. Time complexity: O(1) average; O(n) worst.

    See Also:
    tango.util.collection.Map.replaceElement



  • void checkLoadFactor ();
  • Check to see if we are past load factor threshold. If so, resize so that we are at half of the desired threshold. Also while at it, check to see if we are empty so can just unlink table.

  • int hashOf (K key);
  • Mask off and remainder the hashCode for element so it can be used as table index

  • void resize (int newCap);


  • void remove_ (V element, bool allOccurrences);


  • void replace_ (V oldElement, V newElement, bool allOccurrences);


  • void checkImplementation ();
  • Implements tango.util.collection.model.View.View. checkImplementation .

    See Also:
    tango.util.collection.model.View.View. checkImplementation



  • template MapIterator (K,V)
  • opApply() has migrated here to mitigate the virtual call on method get()

    :: page rendered by CandyDoc