PIP.Collections
Class Pair<O>

java.lang.Object
  extended by PIP.Collections.Persistent.AbstractCollection<E>
      extended by PIP.Collections.Persistent.AbstractList
          extended by PIP.Collections.Pair<O>
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection, java.util.List
Direct Known Subclasses:
SymmetricPair

public class Pair<O>
extends AbstractList


Field Summary
 O o1
           
 O o2
           
 
Constructor Summary
Pair(O o1, O o2)
           
 
Method Summary
 boolean areValuesEqual()
           
 boolean equals(java.lang.Object o)
          Compares the specified object with this list for equality.
 O get(int i)
          Returns the element at the specified position in this list.
 O getFirst()
           
 O getSecond()
           
 int hashCode()
          Returns the hash code value for this list.
 Pair<O> reversed()
           
 void setFirst(O o)
           
 void setSecond(O o)
           
 int size()
          Returns the number of elements in this collection.
 void swap()
           
 java.lang.String toString()
          Returns a string representation of this collection.
 
Methods inherited from class PIP.Collections.Persistent.AbstractList
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, set, subList
 
Methods inherited from class PIP.Collections.Persistent.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

o1

public O o1

o2

public O o2
Constructor Detail

Pair

public Pair(O o1,
            O o2)
Method Detail

size

public int size()
Description copied from class: AbstractCollection
Returns the number of elements in this collection. If the collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.List
Specified by:
size in class AbstractCollection
Returns:
the number of elements in this collection.

getFirst

public O getFirst()

setFirst

public void setFirst(O o)

getSecond

public O getSecond()

setSecond

public void setSecond(O o)

get

public O get(int i)
Description copied from class: AbstractList
Returns the element at the specified position in this list.

Specified by:
get in interface java.util.List
Specified by:
get in class AbstractList
Parameters:
i - index of element to return.
Returns:
the element at the specified position in this list.

equals

public boolean equals(java.lang.Object o)
Description copied from class: AbstractList
Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order.

This implementation first checks if the specified object is this list. If so, it returns true; if not, it checks if the specified object is a list. If not, it returns false; if so, it iterates over both lists, comparing corresponding pairs of elements. If any comparison returns false, this method returns false. If either iterator runs out of elements before the other it returns false (as the lists are of unequal length); otherwise it returns true when the iterations complete.

Specified by:
equals in interface java.util.Collection
Specified by:
equals in interface java.util.List
Overrides:
equals in class AbstractList
Parameters:
o - the object to be compared for equality with this list.
Returns:
true if the specified object is equal to this list.

areValuesEqual

public boolean areValuesEqual()

hashCode

public int hashCode()
Description copied from class: AbstractList
Returns the hash code value for this list.

This implementation uses exactly the code that is used to define the list hash stampFilter in the documentation for the List.hashCode method.

Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.List
Overrides:
hashCode in class AbstractList
Returns:
the hash code value for this list.

toString

public java.lang.String toString()
Description copied from class: AbstractCollection
Returns a string representation of this collection. The string representation consists of a list of the collection's elements in the order they are returned by its iterator, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String.valueOf(Object).

This implementation creates an empty string buffer, appends a left square bracket, and iterates over the collection appending the string representation of each element in turn. After appending each element except the last, the string ", " is appended. Finally a right bracket is appended. A string is obtained from the string buffer, and returned.

Overrides:
toString in class AbstractCollection
Returns:
a string representation of this collection.

swap

public void swap()

reversed

public Pair<O> reversed()