JAPI 0.9.0
Yet another Java API
API Documentation

net.sf.japi.util
Class Table<T1,T2>

java.lang.Object
  extended by net.sf.japi.util.Table<T1,T2>

public class Table<T1,T2>
extends Object

A special Collection class that is like a Map but which allows duplicate keys. Only duplicate key/value pairs aren't allowed. The key therefor is named first, the value second. Uniqueness is gained with Key/Value pairs.

Author:
Christian Hujer

Constructor Summary
Table()
          Create a table.
 
Method Summary
 void clear()
          Completely Clear the table.
 Collection<T1> getFirstsBySecond(T2 second)
          Get all firsts that match the second.
 Collection<Pair<T1,T2>> getPairsByFirst(T1 first)
          Get all pairs that match the first.
 Collection<Pair<T1,T2>> getPairsBySecond(T2 second)
          Get all pairs that match the second.
 Collection<T2> getSecondsByFirst(T1 first)
          Get all seconds that match the first.
 boolean putPair(Pair<T1,T2> pair)
          Put a pair into the table.
 boolean putPair(T1 t1, T2 t2)
          Put a pair into the table.
 boolean removeAllFirst(T1 first)
          Remove all pairs that match a first.
 boolean removeAllSecond(T2 second)
          Remove all pairs that match a second.
 boolean removePair(Pair<T1,T2> pair)
          Remove a pair from the table.
 boolean removePair(T1 t1, T2 t2)
          Remove a pair into the table.
 int size()
          Get the size of the table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Table

public Table()
Create a table.

Method Detail

clear

public void clear()
Completely Clear the table.


getFirstsBySecond

public Collection<T1> getFirstsBySecond(T2 second)
Get all firsts that match the second.

Parameters:
second - second to match
Returns:
all firsts that match second

getPairsByFirst

public Collection<Pair<T1,T2>> getPairsByFirst(T1 first)
Get all pairs that match the first.

Parameters:
first - first to match
Returns:
all pairs that match first

getPairsBySecond

public Collection<Pair<T1,T2>> getPairsBySecond(T2 second)
Get all pairs that match the second.

Parameters:
second - second to match
Returns:
all pairs that match second

getSecondsByFirst

public Collection<T2> getSecondsByFirst(T1 first)
Get all seconds that match the first.

Parameters:
first - first to match
Returns:
all seconds that match first

putPair

public boolean putPair(Pair<T1,T2> pair)
Put a pair into the table.

Parameters:
pair - pair to put into the table
Returns:
true if the table did not already contain that pair, otherwise false

putPair

public boolean putPair(T1 t1,
                       T2 t2)
Put a pair into the table.

Parameters:
t1 - first of pair
t2 - second of pair
Returns:
true if the table did not already contain that pair, otherwise false

removeAllFirst

public boolean removeAllFirst(T1 first)
Remove all pairs that match a first.

Parameters:
first - first to match
Returns:
whether a matching pair was removed
Return Values:
true if at least one pair was removed, false if no matching pairs were found

removeAllSecond

public boolean removeAllSecond(T2 second)
Remove all pairs that match a second.

Parameters:
second - second to match
Returns:
whether a matching pair was removed
Return Values:
true if at least one pair was removed, false if no matching pairs were found

removePair

public boolean removePair(Pair<T1,T2> pair)
Remove a pair from the table.

Parameters:
pair - pair to remove
Returns:
true if the table contained the pair, thus the pair was successfully removed, otherwise false

removePair

public boolean removePair(T1 t1,
                          T2 t2)
Remove a pair into the table.

Parameters:
t1 - first of pair
t2 - second of pair
Returns:
true if the table did not already contain that pair, otherwise false

size

public int size()
Get the size of the table.

Returns:
size of the table

JAPI
Yet another Java API
API Documentation

© 2005-2006 Christian Hujer. All rights reserved. See copyright