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.10 2006/03/14 02:29:31 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.
 void clear()
          Removes all associations from 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.
 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
size, 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>

clear

public void clear()
Description copied from class: Relation3
Removes all associations from this ternary relation.

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


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