TUM CCSM Commons

edu.tum.cs.commons.collections
Class PairList<S,T>

java.lang.Object
  extended by edu.tum.cs.commons.collections.PairList<S,T>

public class PairList<S,T>
extends java.lang.Object

A list for storing pairs in a specific order.

Version:
$Rev: 28497 $
Author:
hummelb, $Author: deissenb $
Rating:
GREEN Hash: 5510B017A5CFB62174A38A897F2160AD

Constructor Summary
PairList()
          Constructor.
PairList(int initialCapacity)
          Constructor.
PairList(PairList<S,T> other)
          Copy constructor.
 
Method Summary
 void add(S first, T second)
          Add the given pair to the list.
 void addAll(PairList<S,T> other)
          Adds all pairs from another list.
 void clear()
          Clears this list.
protected  void ensureSpace(int space)
          Make sure there is space for at least the given amount of elements.
 java.util.List<S> extractFirstList()
          Creates a new list containing all first elements.
 java.util.List<T> extractSecondList()
          Creates a new list containing all second elements.
 S getFirst(int i)
          Returns the first element at given index.
 T getSecond(int i)
          Returns the second element at given index.
 boolean isEmpty()
          Returns whether the list is empty.
 void removeLast()
          Removes the last element of the list.
 void setFirst(int i, S value)
          Sets the first element at given index.
 void setSecond(int i, T value)
          Sets the first element at given index.
 int size()
          Returns the size of the list.
 void swapPairs()
          Swaps the pairs of this list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PairList

public PairList()
Constructor.


PairList

public PairList(int initialCapacity)
Constructor.


PairList

public PairList(PairList<S,T> other)
Copy constructor.

Method Detail

isEmpty

public boolean isEmpty()
Returns whether the list is empty.


size

public int size()
Returns the size of the list.


add

public void add(S first,
                T second)
Add the given pair to the list.


addAll

public void addAll(PairList<S,T> other)
Adds all pairs from another list.


ensureSpace

protected void ensureSpace(int space)
Make sure there is space for at least the given amount of elements.


getFirst

public S getFirst(int i)
Returns the first element at given index.


setFirst

public void setFirst(int i,
                     S value)
Sets the first element at given index.


getSecond

public T getSecond(int i)
Returns the second element at given index.


setSecond

public void setSecond(int i,
                      T value)
Sets the first element at given index.


extractFirstList

public java.util.List<S> extractFirstList()
Creates a new list containing all first elements.


extractSecondList

public java.util.List<T> extractSecondList()
Creates a new list containing all second elements.


swapPairs

public void swapPairs()
Swaps the pairs of this list. Is S and T are different types, this will be extremely dangerous.


clear

public void clear()
Clears this list.


removeLast

public void removeLast()
Removes the last element of the list.


TUM CCSM Commons

TUM CCSM Commons - 2.7