com.roboprogs.util.hash

Class Hash


public class Hash
extends java.lang.Object

A utility class to make it easier to do some things with java Maps similar to Perl / Ruby "hash" idioms.

Note that I did not (yet) use java 1.5 style templated types. Given the weakly typed, dynamic language, code style that this class is helping to emulate, this is probably no loss.

Created by: Rob Anderson.

Released under the LGPL.

Method Summary

static void
main(String[] argv)
Test harness for Hash utility.
static Map
mapPutAll(Map map, Object[] keyValPairs)
Fill a Map with entries from the given array.
static Map
newMap(Object[] keyValPairs)
Return a Map constructed from the given array.

Method Details

main

public static void main(String[] argv)
Test harness for Hash utility. TODO: junit?

mapPutAll

public static Map mapPutAll(Map map,
                            Object[] keyValPairs)
Fill a Map with entries from the given array. TODO: templated java 1.5 types?
Parameters:
map - an existing Map, to which the entries will be added.
keyValPairs - pairs of values, the first of each is the key, the next the value.

newMap

public static Map newMap(Object[] keyValPairs)
Return a Map constructed from the given array. TODO: templated java 1.5 types?
Parameters:
keyValPairs - pairs of values, the first of each is the key, the next the value.