javatools.datatypes
Class DoubleHashMap<K>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<K>
          extended by javatools.datatypes.DoubleHashMap<K>
Type Parameters:
K -
All Implemented Interfaces:
java.lang.Iterable<K>, java.util.Collection<K>, java.util.Set<K>

public class DoubleHashMap<K>
extends java.util.AbstractSet<K>

This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools). It is licensed under the Creative Commons Attribution License (see http://creativecommons.org/licenses/by/3.0) by the YAGO-NAGA team (see http://mpii.de/yago-naga). This class implements a HashMap with double values.

Author:
Fabian M. Suchanek

Constructor Summary
DoubleHashMap()
          Constructor
DoubleHashMap(K... keys)
          Creates a DoubleHashMap with these keys set to 1
 
Method Summary
 void add(java.util.Collection<K> set)
          increases the counters
 void add(DoubleHashMap<K> countBindings)
          Adds all integer values up
 boolean add(K e)
           
 boolean add(K key, double delta)
          Increases a value, true for 'added new key with delta as value', false for 'increased existing value'
 void clear()
           
 double computeSum()
          Computes the sum
 boolean contains(java.lang.Object o)
           
 boolean containsKey(java.lang.Object key)
          True if value is there
 java.util.List<K> decreasingKeys()
          returns the keys in decreasing order
 boolean equals(java.lang.Object o)
           
 double findMax()
          Finds the maximum value
 double get(K key)
          Retrieves a value
 double get(K key, int defaultValue)
          Retrieves a value
 int hashCode()
           
 boolean increase(K key)
          Increases a value, true for 'added new key with value 1', false for 'increased existing value'
 java.util.List<K> increasingKeys()
          returns the keys in increasing order
 java.util.Iterator<K> iterator()
           
 PeekIterator<K> keys()
          Returns keys.
static void main(java.lang.String[] args)
          Test
 boolean put(K key, double value)
          Adds a key, true for 'added the key as new', false for 'overwrote existing value'
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.util.AbstractSet
removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, remove, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, isEmpty, remove, retainAll, toArray, toArray
 

Constructor Detail

DoubleHashMap

public DoubleHashMap()
Constructor


DoubleHashMap

public DoubleHashMap(K... keys)
Creates a DoubleHashMap with these keys set to 1

Method Detail

get

public double get(K key)
Retrieves a value


get

public double get(K key,
                  int defaultValue)
Retrieves a value


containsKey

public boolean containsKey(java.lang.Object key)
True if value is there


add

public boolean add(K key,
                   double delta)
Increases a value, true for 'added new key with delta as value', false for 'increased existing value'


increase

public boolean increase(K key)
Increases a value, true for 'added new key with value 1', false for 'increased existing value'


keys

public PeekIterator<K> keys()
Returns keys. Can be used only once.


put

public boolean put(K key,
                   double value)
Adds a key, true for 'added the key as new', false for 'overwrote existing value'


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Test

Throws:
java.lang.Exception

iterator

public java.util.Iterator<K> iterator()
Specified by:
iterator in interface java.lang.Iterable<K>
Specified by:
iterator in interface java.util.Collection<K>
Specified by:
iterator in interface java.util.Set<K>
Specified by:
iterator in class java.util.AbstractCollection<K>

size

public int size()
Specified by:
size in interface java.util.Collection<K>
Specified by:
size in interface java.util.Set<K>
Specified by:
size in class java.util.AbstractCollection<K>

add

public boolean add(K e)
Specified by:
add in interface java.util.Collection<K>
Specified by:
add in interface java.util.Set<K>
Overrides:
add in class java.util.AbstractCollection<K>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<K>
Specified by:
clear in interface java.util.Set<K>
Overrides:
clear in class java.util.AbstractCollection<K>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<K>
Specified by:
contains in interface java.util.Set<K>
Overrides:
contains in class java.util.AbstractCollection<K>

add

public void add(DoubleHashMap<K> countBindings)
Adds all integer values up


add

public void add(java.util.Collection<K> set)
increases the counters


toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractCollection<K>

increasingKeys

public java.util.List<K> increasingKeys()
returns the keys in increasing order


decreasingKeys

public java.util.List<K> decreasingKeys()
returns the keys in decreasing order


equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Collection<K>
Specified by:
equals in interface java.util.Set<K>
Overrides:
equals in class java.util.AbstractSet<K>

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection<K>
Specified by:
hashCode in interface java.util.Set<K>
Overrides:
hashCode in class java.util.AbstractSet<K>

findMax

public double findMax()
Finds the maximum value


computeSum

public double computeSum()
Computes the sum