org.eclipse.emf.henshin.interpreter.impl
Class PartitionedEGraphImpl

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by java.util.HashSet<E>
              extended by java.util.LinkedHashSet<EObject>
                  extended by org.eclipse.emf.henshin.interpreter.impl.EGraphImpl
                      extended by org.eclipse.emf.henshin.interpreter.impl.PartitionedEGraphImpl
All Implemented Interfaces:
Serializable, Cloneable, Iterable<EObject>, Collection<EObject>, Set<EObject>, EGraph, PartitionedEGraph

public class PartitionedEGraphImpl
extends EGraphImpl
implements PartitionedEGraph

Default implementation of PartitionedEGraph.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.eclipse.emf.henshin.interpreter.impl.EGraphImpl
crossReferenceAdapter, domainMap, inheritanceMap, packages
 
Constructor Summary
PartitionedEGraphImpl(Collection<? extends EObject> collection, int numPartitions)
          Convenience constructor.
PartitionedEGraphImpl(EObject object, int partitionCount)
          Convenience constructor.
PartitionedEGraphImpl(int numPartitions)
          Default constructor.
PartitionedEGraphImpl(Resource resource, int numPartitions)
          Convenience constructor.
 
Method Summary
protected  void addChildParentRelation(EClass child, EClass parent)
          Update the inheritance map.
 void clear()
           
protected  void didAdd(EObject object)
          Notify that an object has been added to the graph.
protected  void didRemove(EObject object)
          Notify that an object has been removed from the graph.
 List<EObject> getDomain(EClass type, boolean strict)
          Get all EObjects of this graph which are compatible with the given type.
 List<EObject> getDomain(EClass type, boolean strict, int partition)
          Get all EObjects of this graph which are compatible with the given type and are in a given partition.
protected  Collection<EObject> getDomain(EClass type, int partition)
          Get the domain for a given type and partition.
 int getDomainSize(EClass type, boolean strict)
          Returns the size of the domain for a type.
 int getDomainSize(EClass type, boolean strict, int partition)
          Returns the size of the domain for a type in a partition.
protected  int getNextPartition(EClass type)
          Get the next partition to use for adding a new object.
 int getNumPartitions()
          Get the number of partitions of this partitioned graph.
protected  List<EClass> getPartitionTypes(EClass type)
          Get the list of proxy partition types for a (real) type.
protected  void initializePartitions(int numPartitions)
          Initialize the partitioned graph.
 
Methods inherited from class org.eclipse.emf.henshin.interpreter.impl.EGraphImpl
add, addAll, addEPackage, addGraph, addTree, copy, getCrossReferenceAdapter, getDomain, getRoots, initializeContents, remove, removeAll, removeGraph, removeTree, toString
 
Methods inherited from class java.util.HashSet
clone, contains, isEmpty, iterator, size
 
Methods inherited from class java.util.AbstractSet
equals, hashCode
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.emf.henshin.interpreter.EGraph
addGraph, addTree, copy, getCrossReferenceAdapter, getRoots, removeGraph, removeTree
 
Methods inherited from interface java.util.Collection
add, addAll, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.Set
contains, containsAll, equals, hashCode, isEmpty, iterator, retainAll, size, toArray, toArray
 

Constructor Detail

PartitionedEGraphImpl

public PartitionedEGraphImpl(int numPartitions)
Default constructor.

Parameters:
numPartitions - Number of partitions to use.

PartitionedEGraphImpl

public PartitionedEGraphImpl(EObject object,
                             int partitionCount)
Convenience constructor. Adds an object and all reachable objects to this graph.

Parameters:
object - An object.
partitionCount - Number of partitions to use.

PartitionedEGraphImpl

public PartitionedEGraphImpl(Collection<? extends EObject> collection,
                             int numPartitions)
Convenience constructor. Adds a collection of objects and all reachable objects to this graph.

Parameters:
collection - A collection of objects.
numPartitions - Number of partitions to use.

PartitionedEGraphImpl

public PartitionedEGraphImpl(Resource resource,
                             int numPartitions)
Convenience constructor. Adds the contents of a resource and all reachable objects to this graph.

Parameters:
resource - A resource.
numPartitions - Number of partitions to use.
Method Detail

initializePartitions

protected void initializePartitions(int numPartitions)
Initialize the partitioned graph.

Parameters:
numPartitions - Number of partitions.

didAdd

protected void didAdd(EObject object)
Description copied from class: EGraphImpl
Notify that an object has been added to the graph.

Overrides:
didAdd in class EGraphImpl
Parameters:
object - Added object.

didRemove

protected void didRemove(EObject object)
Description copied from class: EGraphImpl
Notify that an object has been removed from the graph.

Overrides:
didRemove in class EGraphImpl
Parameters:
object - Removed object.

getNextPartition

protected int getNextPartition(EClass type)
Get the next partition to use for adding a new object.

Parameters:
type - The (real) type of the object.
Returns:
The index of the partition to use.

addChildParentRelation

protected void addChildParentRelation(EClass child,
                                      EClass parent)
Description copied from class: EGraphImpl
Update the inheritance map. Add a child-parent relationship.

Overrides:
addChildParentRelation in class EGraphImpl
Parameters:
child - Child class.
parent - Parent class.

getNumPartitions

public int getNumPartitions()
Description copied from interface: PartitionedEGraph
Get the number of partitions of this partitioned graph.

Specified by:
getNumPartitions in interface PartitionedEGraph
Returns:
The number of partitions.

clear

public void clear()
Specified by:
clear in interface Collection<EObject>
Specified by:
clear in interface Set<EObject>
Overrides:
clear in class EGraphImpl

getDomain

public List<EObject> getDomain(EClass type,
                               boolean strict)
Description copied from interface: EGraph
Get all EObjects of this graph which are compatible with the given type. This returns a fresh and modifiable list.

Specified by:
getDomain in interface EGraph
Overrides:
getDomain in class EGraphImpl
Parameters:
type - The type of the objects.
strict - Whether subtypes are excluded from the result.
Returns:
A set of EObjects compatible with the type.

getDomainSize

public int getDomainSize(EClass type,
                         boolean strict)
Description copied from interface: EGraph
Returns the size of the domain for a type. The returned number equals the size of the list returned by EGraph.getDomain(EClass, boolean). This method should be used whenever the actual objects are not needed.

Specified by:
getDomainSize in interface EGraph
Overrides:
getDomainSize in class EGraphImpl
Parameters:
type - The type.
strict - Whether subtypes are excluded.
Returns:
The size of the domain.

getDomain

public List<EObject> getDomain(EClass type,
                               boolean strict,
                               int partition)
Description copied from interface: PartitionedEGraph
Get all EObjects of this graph which are compatible with the given type and are in a given partition. The partition must be greater or equal zero and strictly less than the number of partitions of this graph. This returns a fresh and modifiable list.

Specified by:
getDomain in interface PartitionedEGraph
Parameters:
type - The type of the objects.
strict - Whether subtypes are excluded from the result.
partition - The partition to be used.
Returns:
A set of EObjects compatible with the type.

getDomainSize

public int getDomainSize(EClass type,
                         boolean strict,
                         int partition)
Description copied from interface: PartitionedEGraph
Returns the size of the domain for a type in a partition. The returned number equals the size of the list returned by PartitionedEGraph.getDomain(EClass, boolean, int). This method should be used whenever the actual objects are not needed.

Specified by:
getDomainSize in interface PartitionedEGraph
Parameters:
type - The type.
strict - Whether subtypes are excluded.
partition - The partition to be used.
Returns:
The size of the domain.

getPartitionTypes

protected List<EClass> getPartitionTypes(EClass type)
Get the list of proxy partition types for a (real) type.

Parameters:
type - The actual object type.
Returns:
List of proxy partition types.

getDomain

protected Collection<EObject> getDomain(EClass type,
                                        int partition)
Get the domain for a given type and partition.

Parameters:
type - An object type.
partition - A partition index.
Returns:
The domain.