jpaul.DataStructs
Class Relation3MapRelImpl<Ta,Tb,Tc>

java.lang.Object
  extended by jpaul.DataStructs.Relation3<Ta,Tb,Tc>
      extended by jpaul.DataStructs.Relation3MapRelImpl<Ta,Tb,Tc>

public class Relation3MapRelImpl<Ta,Tb,Tc>
extends Relation3<Ta,Tb,Tc>

Relation3MapRelImpl is a simple implementation of Relation3, backed by a Map from Ta keys to RelationTb,Tc between Tb and Tc.

Version:
$Id: Relation3MapRelImpl.java,v 1.5 2005/10/31 22:30:12 salcianu Exp $
Author:
Alexandru Salcianu - salcianu@alum.mit.edu

Constructor Summary
Relation3MapRelImpl()
          Creates a Relation3MapRelImpl object using a factory of LinkedHashMaps and a factory of MapSetRelations.
Relation3MapRelImpl(MapFactory<Ta,Relation<Tb,Tc>> mapFact, RelationFactory<Tb,Tc> relFact)
          Creates a Relation3MapRelImpl.
 
Method Summary
 boolean add(Ta a, Tb b, Tc c)
          Adds the triple <a,b,c> to this ternary relation.
 boolean contains(Ta a, Tb b, Tc c)
          Checks the presence of the triple <a,b,c> in this ternary relation.
 java.util.Collection<Tb> get2ndValues(Ta a)
          Returns the elements that appear in the 2nd position of at least one triple that appears in this ternary relation and has a in its 1st position.
 java.util.Collection<Tc> get3rdValues(Ta a, Tb b)
          Returns the elements that appear in the third position of at least one triple of the form <a,b,*%gt; that appears in this ternary relation.
 java.util.Collection<Ta> getKeys()
          Returns the elements that appear in the 1st position of at least one triple from this ternary relation.
static void main(java.lang.String[] args)
           
 boolean remove(Ta a, Tb b, Tc c)
          Removes the triple <a,b,c> from this ternary relation.
 
Methods inherited from class jpaul.DataStructs.Relation3
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Relation3MapRelImpl

public Relation3MapRelImpl(MapFactory<Ta,Relation<Tb,Tc>> mapFact,
                           RelationFactory<Tb,Tc> relFact)
Creates a Relation3MapRelImpl. This constructor allows the user to indicate what map and relation implementations he wants to use. Therefore, this constructor is good while finely-tuning the performances of an application using a large number of small ternary relations.


Relation3MapRelImpl

public Relation3MapRelImpl()
Creates a Relation3MapRelImpl object using a factory of LinkedHashMaps and a factory of MapSetRelations. This default constructor consumes a lot of memory but should work just fine for large and not-very-frequent ternary relations.

Method Detail

add

public boolean add(Ta a,
                   Tb b,
                   Tc c)
Description copied from class: Relation3
Adds the triple <a,b,c> to this ternary relation.

Specified by:
add in class Relation3<Ta,Tb,Tc>

remove

public boolean remove(Ta a,
                      Tb b,
                      Tc c)
Description copied from class: Relation3
Removes the triple <a,b,c> from this ternary relation.

Specified by:
remove in class Relation3<Ta,Tb,Tc>

contains

public boolean contains(Ta a,
                        Tb b,
                        Tc c)
Description copied from class: Relation3
Checks the presence of the triple <a,b,c> in this ternary relation.

Specified by:
contains in class Relation3<Ta,Tb,Tc>

getKeys

public java.util.Collection<Ta> getKeys()
Description copied from class: Relation3
Returns the elements that appear in the 1st position of at least one triple from this ternary relation. Unmodifiable view.

Specified by:
getKeys in class Relation3<Ta,Tb,Tc>

get2ndValues

public java.util.Collection<Tb> get2ndValues(Ta a)
Description copied from class: Relation3
Returns the elements that appear in the 2nd position of at least one triple that appears in this ternary relation and has a in its 1st position. Unmodifiable view.

Specified by:
get2ndValues in class Relation3<Ta,Tb,Tc>

get3rdValues

public java.util.Collection<Tc> get3rdValues(Ta a,
                                             Tb b)
Description copied from class: Relation3
Returns the elements that appear in the third position of at least one triple of the form <a,b,*%gt; that appears in this ternary relation.

Specified by:
get3rdValues in class Relation3<Ta,Tb,Tc>

main

public static void main(java.lang.String[] args)


Copyright 2005 Alexandru Salcianu - salcianu@alum.mit.edu