|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.CrossRefList
public final class CrossRefList
CrossRefList is a list that maintains pointers to other CrossRefLists. CrossRefList is meant to be used to keep track of links between ports and relations in Ptolemy II. It is a highly specialized form of a list. An instance has a container (an Object), which is immutable, meaning that the container cannot be changed after the instance is constructed. CrossRefList enumerators and query methods do not return references to other CrossRefLists; instead, references to the containers of the CrossRefLists (which can be any Object) are returned.
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) |
Nested Class Summary | |
---|---|
protected class |
CrossRefList.CrossRef
Objects of this type form the elements of the list. |
private class |
CrossRefList.CrossRefEnumeration
Enumerate the objects pointed to by the list. |
Field Summary | |
---|---|
private java.lang.Object |
_container
|
private CrossRefList.CrossRef |
_headNode
|
private CrossRefList.CrossRef |
_lastNode
|
private long |
_listVersion
|
private int |
_size
|
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private long _listVersion
private int _size
private CrossRefList.CrossRef _headNode
private CrossRefList.CrossRef _lastNode
private java.lang.Object _container
Constructor Detail |
---|
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.Method Detail |
---|
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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |