javatools.datatypes
Class IntHashMap<K>

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

public class IntHashMap<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 integer values.

Author:
Fabian M. Suchanek

Constructor Summary
IntHashMap()
          Constructor
IntHashMap(java.util.Collection<K> keys)
          Creates an intHashMap with these keys set to 1
IntHashMap(K... keys)
          Creates an intHashMap with these keys set to 1
IntHashMap(java.util.Map<K,IntHashMap<K>> map)
          Creates an intHashMap with the same keys and the sizes
 
Method Summary
 void add(java.util.Collection<K> set)
          increases the counters
 void add(IntHashMap<K> countBindings)
          Adds all integer values up
 boolean add(K e)
           
 boolean add(K key, int delta)
          Increases a value, true for 'added new key with delta as value', false for 'increased existing value'
 void addAll(IntHashMap<K> countBindings)
          Adds all integer values up
 void clear()
           
 long 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)
           
 int findMax()
          Finds the maximum value
 int get(java.lang.Object key)
          Retrieves a value
 int get(java.lang.Object 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, int 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

IntHashMap

public IntHashMap()
Constructor


IntHashMap

public IntHashMap(K... keys)
Creates an intHashMap with these keys set to 1


IntHashMap

public IntHashMap(java.util.Collection<K> keys)
Creates an intHashMap with these keys set to 1


IntHashMap

public IntHashMap(java.util.Map<K,IntHashMap<K>> map)
Creates an intHashMap with the same keys and the sizes

Method Detail

get

public int get(java.lang.Object key)
Retrieves a value


get

public int get(java.lang.Object 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,
                   int 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,
                   int 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(IntHashMap<K> countBindings)
Adds all integer values up


addAll

public void addAll(IntHashMap<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 int findMax()
Finds the maximum value


computeSum

public long computeSum()
Computes the sum