container
Class HashDecorable

java.lang.Object
  |
  +--container.HashDecorable
All Implemented Interfaces:
Decorable
Direct Known Subclasses:
StoredDirectedEdge, StoredVertex

public class HashDecorable
extends java.lang.Object
implements Decorable

This class should typically be extended so that it implements other interfaces besides Decorable. So far, it stores only decorations but no data! Each instance of the class is a position that stores its attributes and their values in a hash table. We assume there will be a lot of positions, and probably not very many attributes per position, so we try to keep the hash table at each position small or nonexistent.


Field Summary
protected  java.util.Map m
          Maps attributes of this object to their values.
 
Constructor Summary
HashDecorable()
          Constructor.
 
Method Summary
 java.lang.Object get(container.Attribute a)
           
 boolean has(container.Attribute a)
          Does this object currently have any value for this attribute?
 java.lang.Object put(container.Attribute a, java.lang.Object o)
          Makes this object store o as the value of attribute a.
 java.lang.Object remove(container.Attribute a)
          Removes attribute a and its associated value from this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m

protected java.util.Map m
Maps attributes of this object to their values. If there are no attributes, we save memory by making the map null rather than an empty HashMap.

Constructor Detail

HashDecorable

public HashDecorable()
Constructor. No attributes to start with.

Method Detail

has

public boolean has(container.Attribute a)
Description copied from interface: Decorable
Does this object currently have any value for this attribute? (Asking has(a) is clearer than asking get(a)!=null, and it distinguishes between no value and a value that happens to be null.)

Specified by:
has in interface Decorable

get

public java.lang.Object get(container.Attribute a)
Specified by:
get in interface Decorable
Returns:
this object's value for attribute a, or null if no such value is currently stored.

put

public java.lang.Object put(container.Attribute a,
                            java.lang.Object o)
Description copied from interface: Decorable
Makes this object store o as the value of attribute a.

Specified by:
put in interface Decorable
Returns:
previous value, or null if there was none

remove

public java.lang.Object remove(container.Attribute a)
Description copied from interface: Decorable
Removes attribute a and its associated value from this object.

Specified by:
remove in interface Decorable
Returns:
previous value, or null if there was none