org.planx.util
Class ObjectReference<E>

java.lang.Object
  extended by org.planx.util.ObjectReference<E>
Direct Known Subclasses:
LocalLocator

public class ObjectReference<E>
extends Object

An ObjectReference points to an object and can be updated behind-the-scenes to point to another object without the user noticing. The updating is done using union-find techniques. Currently, only path compression is done. Union-by-rank should be added in the future.

The implementation is not synchronized.

Author:
Thomas Ambus

Constructor Summary
ObjectReference(E obj)
          Creates a new ObjectReference pointing to the specified object.
 
Method Summary
 boolean equals(Object o)
          Two ObjectReferences are equal if and only if the objects that they point to are equal.
 E get()
          Returns the object pointed to.
 int hashCode()
          Returns the hash code of the object pointed to.
 void move(ObjectReference<E> ref)
          Lets this ObjectReference point to the same actual object as the specified ObjectReference.
 String toString()
          Returns the result of invoking the toString method on the object pointed to.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectReference

public ObjectReference(E obj)
Creates a new ObjectReference pointing to the specified object.

Method Detail

get

public E get()
Returns the object pointed to.


move

public void move(ObjectReference<E> ref)
Lets this ObjectReference point to the same actual object as the specified ObjectReference.


equals

public boolean equals(Object o)
Two ObjectReferences are equal if and only if the objects that they point to are equal.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the hash code of the object pointed to.

Overrides:
hashCode in class Object

toString

public String toString()
Returns the result of invoking the toString method on the object pointed to.

Overrides:
toString in class Object


Copyright © 2004-2005 Plan-X. All Rights Reserved.