infovis.utils
Class IntSortedMap

java.lang.Object
  extended by infovis.utils.IntSortedMap

public class IntSortedMap
extends Object

Association Map using ints as keys.

Version:
$Revision: 1.9 $
Author:
Jean-Daniel Fekete

Constructor Summary
IntSortedMap()
           
IntSortedMap(IntComparator comparator)
           
IntSortedMap(IntSortedMap other)
           
IntSortedMap(IntSortedMap other, IntComparator comp)
          Constructor for IntSortedMap.
 
Method Summary
 void clear()
          Removes all mappings from this TreeMap.
 int compare(int key1, int key2)
           
 boolean containsKey(int key)
          Returns true if this map contains a mapping for the specified key.
 int firstKey()
          Returns the first (lowest) key currently in this sorted map.
 Object get(int key)
          Returns the value to which this map maps the specified key.
 IntComparator getComparator()
           
 boolean isEmpty()
           
 RowIterator keyIterator()
           
 int lastKey()
          Returns the last (highest) key currently in this sorted map.
 Object put(int key, Object value)
          Associates the specified value with the specified key in this map.
 Object remove(int key)
          Removes the mapping for this key from this TreeMap if present.
 int size()
          Returns the number of key-value mappings in this map.
 Iterator valueIterator()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntSortedMap

public IntSortedMap(IntSortedMap other,
                    IntComparator comp)
Constructor for IntSortedMap.


IntSortedMap

public IntSortedMap()

IntSortedMap

public IntSortedMap(IntComparator comparator)

IntSortedMap

public IntSortedMap(IntSortedMap other)
Method Detail

compare

public int compare(int key1,
                   int key2)

size

public int size()
Returns the number of key-value mappings in this map.

Returns:
the number of key-value mappings in this map.

isEmpty

public boolean isEmpty()

containsKey

public boolean containsKey(int key)
Returns true if this map contains a mapping for the specified key.

Parameters:
key - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key.
Throws:
ClassCastException - if the key cannot be compared with the keys currently in the map.
NullPointerException - key is null and this map uses natural ordering, or its comparator does not tolerate null keys.

get

public Object get(int key)
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters:
key - key whose associated value is to be returned.
Returns:
the value to which this map maps the specified key, or null if the map contains no mapping for the key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and this map uses natural ordering, or its comparator does not tolerate null keys.
See Also:
containsKey(int)

firstKey

public int firstKey()
Returns the first (lowest) key currently in this sorted map.

Returns:
the first (lowest) key currently in this sorted map.
Throws:
NoSuchElementException - Map is empty.

lastKey

public int lastKey()
Returns the last (highest) key currently in this sorted map.

Returns:
the last (highest) key currently in this sorted map.
Throws:
NoSuchElementException - Map is empty.

put

public Object put(int key,
                  Object value)
Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and this map uses natural order, or its comparator does not tolerate null keys.

remove

public Object remove(int key)
Removes the mapping for this key from this TreeMap if present.

Parameters:
key - key for which mapping should be removed
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and this map uses natural order, or its comparator does not tolerate null keys.

clear

public void clear()
Removes all mappings from this TreeMap.


keyIterator

public RowIterator keyIterator()

valueIterator

public Iterator valueIterator()

getComparator

public IntComparator getComparator()


Copyright 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.