JUtil

net.cscott.jutil
Class Default.PairList<A,B>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList
          extended by net.cscott.jutil.Default.PairList<A,B>
All Implemented Interfaces:
Serializable, Iterable, Collection, List
Enclosing class:
Default

public static class Default.PairList<A,B>
extends AbstractList
implements Serializable

Pairs, implemented as a List. The Default.PairList implements 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. Note that the hashCode() implementation differs from pairs implemented as Map.Entrys; the parameterization is different as well.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Default.PairList(A left, B right)
           
 
Method Summary
 Object get(int index)
           
 A left()
          Return the left element of the pair (head).
 B right()
          Return the right element of the pair (tail).
 Object set(int index, Object element)
           
 int size()
           
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

Default.PairList

public Default.PairList(A left,
                        B right)
Method Detail

left

public A left()
Return the left element of the pair (head).


right

public B right()
Return the right element of the pair (tail).


size

public int size()
Specified by:
size in interface Collection
Specified by:
size in interface List
Specified by:
size in class AbstractCollection

get

public Object get(int index)
Specified by:
get in interface List
Specified by:
get in class AbstractList

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List
Overrides:
set in class AbstractList

JUtil

Copyright (c) 2006 C. Scott Ananian