edu.stanford.nlp.util
Class Maps

java.lang.Object
  extended by edu.stanford.nlp.util.Maps

public class Maps
extends Object

Utilities for Maps, including inverting, composing, and support for list/set values.

Author:
Dan Klein (klein@cs.stanford.edu) Date: Oct 22, 2003 Time: 8:56:16 PM

Constructor Summary
Maps()
           
 
Method Summary
static Map compose(Map map1, Map map2)
          Compose two maps map1:x->y and map2:y->z to get a map x->z
static Map invert(Map map)
          Inverts a map x->y to a map y->x assuming unique preimages.
static Map invertSet(Map map)
          Inverts a map x->y to a map y->pow(x) not assuming unique preimages.
static void main(String[] args)
           
static void putIntoValueArrayList(Map map, Object key, Object value)
          Adds the value to the ArrayList given by map.get(key), creating a new ArrayList if needed.
static void putIntoValueCollection(Map map, Object key, Object value, CollectionFactory cf)
          Adds the value to the collection given by map.get(key).
static void putIntoValueHashSet(Map map, Object key, Object value)
          Adds the value to the HashSet given by map.get(key), creating a new HashMap if needed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Maps

public Maps()
Method Detail

putIntoValueHashSet

public static void putIntoValueHashSet(Map map,
                                       Object key,
                                       Object value)
Adds the value to the HashSet given by map.get(key), creating a new HashMap if needed.

Parameters:
map -
key -
value -

putIntoValueArrayList

public static void putIntoValueArrayList(Map map,
                                         Object key,
                                         Object value)
Adds the value to the ArrayList given by map.get(key), creating a new ArrayList if needed.

Parameters:
map -
key -
value -

putIntoValueCollection

public static void putIntoValueCollection(Map map,
                                          Object key,
                                          Object value,
                                          CollectionFactory cf)
Adds the value to the collection given by map.get(key). A new collection is created using the supplied CollectionFactory.

Parameters:
map -
key -
value -
cf -

compose

public static Map compose(Map map1,
                          Map map2)
Compose two maps map1:x->y and map2:y->z to get a map x->z

Parameters:
map1 -
map2 -
Returns:
The composed map

invert

public static Map invert(Map map)
Inverts a map x->y to a map y->x assuming unique preimages. If they are not unique, you get an arbitrary ones as the values in the inverted map.

Parameters:
map -
Returns:
The inverted map

invertSet

public static Map invertSet(Map map)
Inverts a map x->y to a map y->pow(x) not assuming unique preimages.

Parameters:
map -
Returns:
The inverted set

main

public static void main(String[] args)


Stanford NLP Group