public final class CrossRefList
extends java.lang.Object
For efficiency, CrossRefList maintains a list of pairwise links between Objects (CrossRefs). That is, each member of a set of objects has a list of references to other members of the set, and each reference has a similar list that contains a corresponding back reference. Each reference list is an instance of . The class is used as if it were a simple list of references to objects, but it ensures the symmetry of the references, and supports efficient removal of links. Removing a reference in one list automatically updates N back-references in O(N) time, independent of the sizes of the cross-referenced lists.
It is possible to create links at specified points in the list (called the index number). This may result in gaps in the list at lower index numbers. Gaps are representing by null in an enumeration of the list.
Green (bart) |
Green (eal) |
Modifier and Type | Class and Description |
---|---|
protected class |
CrossRefList.CrossRef
Objects of this type form the elements of the list.
|
Constructor and Description |
---|
CrossRefList(java.lang.Object container)
Construct a list with the specified container.
|
CrossRefList(java.lang.Object container,
CrossRefList originalList)
Create a new CrossRefList that is linked to the same
CrossRefLists as the original CrossRefList except that this
new one has a new container.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
first()
Return the first container linked to this list, or
null if the list is empty.
|
java.lang.Object |
get(int index)
Get the container at the specified index.
|
java.util.Enumeration |
getContainers()
Enumerate the containers linked to this list.
|
void |
insertLink(int index,
CrossRefList farList)
Insert a link to the specified CrossRefList (farList) at
the specified position (index).
|
boolean |
isLinked(java.lang.Object obj)
Return true if the specified container is linked to this
list.
|
void |
link(CrossRefList farList)
Link this list to a different CrossRefList (farList).
|
int |
size()
Return size of this list.
|
void |
unlink(int index)
Delete the link at the specified index.
|
void |
unlink(java.lang.Object obj)
Delete all links to the specified container.
|
void |
unlinkAll()
Delete all cross references.
|
public CrossRefList(java.lang.Object container)
container
- The container of the object to be constructed.public CrossRefList(java.lang.Object container, CrossRefList originalList)
container
- The container of the object to be constructed.originalList
- The model to copy.public java.lang.Object first()
public java.lang.Object get(int index)
index
- The index of the container to return.public java.util.Enumeration getContainers()
public void insertLink(int index, CrossRefList farList) throws IllegalActionException
Note that this method specifies the index on the local reference list, but not on the remote reference list. There is no mechanism provided to specify both indices. This is because this class is used to linked ports to relations, and indices of links have no meaning in relations. Thus, there is no need for a richer interface.
Note that this method does not synchronize on the remote object. Thus, this method should be called within a write-synchronization of the common workspace.
index
- The position in the list at which to insert this link.farList
- The cross reference list contained by the remote object.IllegalActionException
- If this list tries linking to
itself.public boolean isLinked(java.lang.Object obj)
obj
- An object that might be referenced.public void link(CrossRefList farList) throws IllegalActionException
farList
- The cross reference list contained by the remote object.IllegalActionException
- If this list tries linking to
itself.public int size()
public void unlink(int index)
index
- The index of the link to delete.public void unlink(java.lang.Object obj)
obj
- The object to delete.public void unlinkAll()