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.
Association(Object)
- Constructs a pair from a key; value is null.
Association(Object, Object)
- Constructs a pair from a key and value.
equals(Object)
- Standard comparison function.
hashCode()
- Standard hashcode function.
key()
- Fetch key from association.
setValue(Object)
- Sets the value of the key-value pair.
toString()
- Standard string representation of an association.
value()
- Fetch value from association.
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.
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.
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
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
value
public Object value()
- Fetch value from association. May return null.
- Postcondition:
- Returns value from association
- Returns:
- The value field of the association.
key
public Object key()
- Fetch key from association. Should not return null.
- Postcondition:
- Returns key from association
- Returns:
- Key of the key-value pair.
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.
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