harpoon.Util
Class Default

java.lang.Object
  |
  +--harpoon.Util.Default

public abstract class Default
extends Object

Default contains one-off or 'standard, no-frills' implementations of simple Iterators, Enumerations, and Comparators.

Version:
$Id: Default.java,v 1.2 2002/02/25 21:08:45 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Field Summary
static Comparator comparator
          A Comparator for objects that implement Comparable.
static SortedMap EMPTY_MAP
          An empty map.
static Enumeration nullEnumerator
          Deprecated. Use nullIterator.
static Iterator nullIterator
          An Iterator over the empty set.
 
Constructor Summary
Default()
           
 
Method Summary
static Map.Entry entry(Object key, Object value)
          A pair constructor method more appropriate for Set views of Maps and MultiMaps.
static List pair(Object left, Object right)
          A pair constructor method.
static Iterator singletonIterator(Object o)
          An Iterator over a singleton set.
static Iterator unmodifiableIterator(Iterator i)
          An unmodifiable version of the given iterator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comparator

public static final Comparator comparator
A Comparator for objects that implement Comparable.


nullEnumerator

public static final Enumeration nullEnumerator
Deprecated. Use nullIterator.

An Enumerator over the empty set.


nullIterator

public static final Iterator nullIterator
An Iterator over the empty set.


EMPTY_MAP

public static final SortedMap EMPTY_MAP
An empty map. Missing from java.util.Collections.

Constructor Detail

Default

public Default()
Method Detail

singletonIterator

public static final Iterator singletonIterator(Object o)
An Iterator over a singleton set.


unmodifiableIterator

public static final Iterator unmodifiableIterator(Iterator i)
An unmodifiable version of the given iterator.


pair

public static List pair(Object left,
                        Object right)
A pair constructor method. Pairs implement hashCode() and equals() "properly" so they can be used as keys in hashtables and etc. They are implemented as mutable lists of fixed size 2.


entry

public static Map.Entry entry(Object key,
                              Object value)
A pair constructor method more appropriate for Set views of Maps and MultiMaps. The returned object is an instance of Map.Entry; the only (real) difference from the pairs returned by Default.pair() is the definition of hashCode(), which corresponds to Map.Entry (being key.hashCode() ^ value.hashCode() ) rather than List (which would be 31*(31+key.hashCode())+value.hashCode() ). This is an annoying distinction; I wish the JDK API authors had made these consistent. The Map.Entry returned is immuatable.