All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class structure.Association

java.lang.Object
    |
    +----structure.Association

public class Association
extends Object
A class implementing a key-value pair. This class associates an immutable key with a mutable value. Used in many other structures.


Constructor Index

 o Association(Object)
Constructs a pair from a key; value is null.
 o Association(Object, Object)
Constructs a pair from a key and value.

Method Index

 o equals(Object)
Standard comparison function.
 o hashCode()
Standard hashcode function.
 o key()
Fetch key from association.
 o setValue(Object)
Sets the value of the key-value pair.
 o toString()
Standard string representation of an association.
 o value()
Fetch value from association.

Constructors

 o Association
public Association(Object key,
                   Object value)
Constructs a pair from a key and value.

Precondition:
Key is non-null.
Postcondition:
Constructs a key-value pair.

Parameters:
key - A non-null object.
value - A (possibly null) object.
 o Association
public Association(Object key)
Constructs a pair from a key; value is null.

Precondition:
Key is non-null
Postcondition:
Constructs a key-value pair.

Parameters:
key - A non-null key value.

Methods

 o equals
public boolean equals(Object other)
Standard comparison function. Comparison based on keys only.

Precondition:
Other is non-null Association
Postcondition:
Returns true iff the keys are equal

Parameters:
other - Another association.
Returns:
True iff the keys are equal.
Overrides:
equals in class Object
 o hashCode
public int hashCode()
Standard hashcode function.

Postcondition:
Return hash code association with this association.

Returns:
A hash code for association.
Overrides:
hashCode in class Object
See Also:
Hashtable
 o value
public Object value()
Fetch value from association. May return null.

Postcondition:
Returns value from association

Returns:
The value field of the association.
 o key
public Object key()
Fetch key from association. Should not return null.

Postcondition:
Returns key from association

Returns:
Key of the key-value pair.
 o setValue
public void setValue(Object value)
Sets the value of the key-value pair.

Postcondition:
Sets association's value to value.

Parameters:
value - The new value.
 o toString
public String toString()
Standard string representation of an association.

Postcondition:
Returns string representation

Returns:
String representing key-value pair.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index