edu.byu.ece.edif.util.graph
Class EdifCellInstanceGroupings

java.lang.Object
  extended by edu.byu.ece.edif.util.graph.EdifCellInstanceGroupings
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
EdifCellBadCutGroupings

public class EdifCellInstanceGroupings
extends java.lang.Object
implements java.io.Serializable

This class organizes EdifCellInstances into logical groups. Each logical group is a EdifCellInstanceCollection object.

This class is not atomic and supports the merging and creation of groups.

TODO: Let's make an interface for this called EdifCellInstanceGroupings and a simple class that implements the interface.

See Also:
Serialized Form

Field Summary
(package private)  EdifCell _cell
          Reference to the cell to which the groupings in this class belong.
(package private)  java.util.Collection<EdifCellInstanceCollection> _edifCellInstanceGroups
          Collection of the groupings created for the EdifCell object _cell *
(package private)  java.util.Map<EdifCellInstance,EdifCellInstanceCollection> _edifCellInstanceGroupsMap
          Map between each EdifCellInstance in the EdifCell object _cell to an EdifCellInstanceCollection grouping of EdifCellInstances.
 
Constructor Summary
  EdifCellInstanceGroupings(EdifCell cell)
           
protected EdifCellInstanceGroupings(EdifCellInstanceGroupings ecig)
           
 
Method Summary
protected  void _init()
           
 java.lang.Object clone()
           
 EdifCellInstanceCollection getGroup(java.lang.Object eci)
          Get a copy of the group to which the specified cell instance belongs.
 java.util.Collection<EdifCellInstanceCollection> getInstanceGroups()
          Get a copy of the list of all the groups.
 int getNumberGroups()
           
 EdifCellInstanceCollection groupInstances(java.util.Collection<EdifCellInstance> ecis)
          Create a new EdifCellInstanceCollection group that contains all EdifCellInstance objects from the specified collection ecis.
 EdifCellInstanceCollection groupInstances(EdifCellInstance e1, EdifCellInstance e2)
          Create a new EdifCellInstanceCollection that contains both EdifCellInstance objects e1 and e2.
 EdifCellInstanceCollection mergeCollections(EdifCellInstanceCollection c1, EdifCellInstanceCollection c2)
          Merges two groups, or EdifCellInstanceCollections.
private  EdifCellInstanceCollection mergeCollectionsFast(EdifCellInstanceCollection c1, EdifCellInstanceCollection c2)
          Merges two groups, or EdifCellInstanceCollections.
 EdifCellInstanceCollection mergeGroupIntoGroup(EdifCellInstanceCollection group1, EdifCellInstanceCollection group2)
          Adds the contents of one existing group to annother existing group (EdifCellInstanceCollection object).
protected  void removeOldSingleInstanceGroups(EdifCellInstanceCollection new_group)
          This method removes a collection of EdifCellInstances (held within and EdifCellInstanceCollection object) from the groups array.
 void retainGroups(java.util.Collection<EdifCellInstanceCollection> ecics)
          Retain all groups in the passed-in Collection of EdifCellInstanceCollection objects.
protected  void updateMap(EdifCellInstanceCollection ecic)
          This method updates the Map of instances to groups.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_cell

EdifCell _cell
Reference to the cell to which the groupings in this class belong. *


_edifCellInstanceGroups

java.util.Collection<EdifCellInstanceCollection> _edifCellInstanceGroups
Collection of the groupings created for the EdifCell object _cell *


_edifCellInstanceGroupsMap

java.util.Map<EdifCellInstance,EdifCellInstanceCollection> _edifCellInstanceGroupsMap
Map between each EdifCellInstance in the EdifCell object _cell to an EdifCellInstanceCollection grouping of EdifCellInstances. Note that a group can be a single instance.

Constructor Detail

EdifCellInstanceGroupings

public EdifCellInstanceGroupings(EdifCell cell)

EdifCellInstanceGroupings

protected EdifCellInstanceGroupings(EdifCellInstanceGroupings ecig)
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

_init

protected void _init()

groupInstances

public EdifCellInstanceCollection groupInstances(java.util.Collection<EdifCellInstance> ecis)
Create a new EdifCellInstanceCollection group that contains all EdifCellInstance objects from the specified collection ecis.

If any instance already belongs to a group, the entire existing group becomes part of the new group, otherwise just the instance itself is added to the group.

Parameters:
ecis - Collection of EdifCellInstances to group with all the other EdifCellInstances.
Returns:
The resulting EdifCellInstanceCollection group containing all instances from ecis.

groupInstances

public EdifCellInstanceCollection groupInstances(EdifCellInstance e1,
                                                 EdifCellInstance e2)
Create a new EdifCellInstanceCollection that contains both EdifCellInstance objects e1 and e2. If either of the instances already belongs to a group, the entire existing group becomes part of the new group.

Parameters:
e1 - EdifCellInstance to group with other EdifCellInstance.
e2 - EdifCellInstance to group with other EdifCellInstance.
Returns:
The resulting EdifCellInstanceCollection group containing e1 and e2.

mergeGroupIntoGroup

public EdifCellInstanceCollection mergeGroupIntoGroup(EdifCellInstanceCollection group1,
                                                      EdifCellInstanceCollection group2)
Adds the contents of one existing group to annother existing group (EdifCellInstanceCollection object). Deletes the first group while simply adding to the second group.

Parameters:
group1 - Group to take from and delete
group2 - Group to add the ECIs to
Returns:
Expanded group, or EdifCellInstanceCollection, containing all instances from groups c1 and c2.
Throws:
EdifRuntimeException - If this object's groups list does not already contain "group".

mergeCollections

public EdifCellInstanceCollection mergeCollections(EdifCellInstanceCollection c1,
                                                   EdifCellInstanceCollection c2)
Merges two groups, or EdifCellInstanceCollections.

Parameters:
c1 - Group to merge with other group.
c2 - Group to merge with other group.
Returns:
Merged group, or EdifCellInstanceCollection, containing all instances from groups c1 and c2.
Throws:
EdifRuntimeException - If this object's groups list does not already contain both c1 and c2.

mergeCollectionsFast

private EdifCellInstanceCollection mergeCollectionsFast(EdifCellInstanceCollection c1,
                                                        EdifCellInstanceCollection c2)
Merges two groups, or EdifCellInstanceCollections. (This version does not check to see if the specified groups already exist. It is up to the caller to guarantee this when calling this version of the method.)

Parameters:
c1 - Group to merge with other group.
c2 - Group to merge with other group.
Returns:
Merged group, or EdifCellInstanceCollection, containing all instances from groups c1 and c2.

updateMap

protected void updateMap(EdifCellInstanceCollection ecic)
This method updates the Map of instances to groups. All instances contained within the specified EdifCellInstanceCollection group ecic, will now have ecic as the value to which they map.

Parameters:
ecic - New group to update in the map.

removeOldSingleInstanceGroups

protected void removeOldSingleInstanceGroups(EdifCellInstanceCollection new_group)
This method removes a collection of EdifCellInstances (held within and EdifCellInstanceCollection object) from the groups array. The method assumes that each EdifCellInstance has a corresponding SingleInstanceCollection object in the groups array.

Parameters:
new_group - The collection of EdifCellInstances which will have their corresponding SingleInstanceCollection removed from the groups array.

getGroup

public EdifCellInstanceCollection getGroup(java.lang.Object eci)
Get a copy of the group to which the specified cell instance belongs.

Parameters:
eci - EdifCellInstance for which its group is requested.
Returns:
Copy of the EdifCellInstanceCollection group to which the specified EdifCellInstance belongs.

getInstanceGroups

public java.util.Collection<EdifCellInstanceCollection> getInstanceGroups()
Get a copy of the list of all the groups. Each item in the Collection is of type EdifCellInstanceCollection.

Returns:
Collection of the EdifCellInstanceCollection groups.

getNumberGroups

public int getNumberGroups()

retainGroups

public void retainGroups(java.util.Collection<EdifCellInstanceCollection> ecics)
Retain all groups in the passed-in Collection of EdifCellInstanceCollection objects. Removes all references to the rest of the ECIs and their corresponding groups.

Parameters:
ecis - Collection of EdifCellInstanceCollection to retain