de.lmu.ifi.dbs.elki.utilities.datastructures.hierarchy
Class HierarchyHashmapList<O>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.datastructures.hierarchy.HierarchyHashmapList<O>
Type Parameters:
O - Object type (arbitrary!)
All Implemented Interfaces:
Hierarchy<O>, ModifiableHierarchy<O>
Direct Known Subclasses:
ResultHierarchy

public class HierarchyHashmapList<O>
extends Object
implements ModifiableHierarchy<O>

Centralized hierarchy implementation, using a HashMap of Lists.


Nested Class Summary
private  class HierarchyHashmapList.ItrAnc
          Iterator over all Ancestors.
private  class HierarchyHashmapList.ItrDesc
          Iterator to collect into the descendants.
 
Field Summary
private  HashMap<O,List<O>> cmap
          The data storage for children
private  HashMap<O,List<O>> pmap
          The data storage for parents
 
Constructor Summary
HierarchyHashmapList()
          Constructor
 
Method Summary
 void add(O parent, O child)
          Add a parent-child relationship.
 List<O> getChildren(O obj)
          Get children list.
 List<O> getParents(O obj)
          Get parents list.
 IterableIterator<O> iterAncestors(O obj)
          Iterate ancestors (recursive parents)
 IterableIterator<O> iterDescendants(O obj)
          Iterate descendants (recursive children)
 int numChildren(O obj)
          Get number of children
 int numParents(O obj)
          Get number of (direct) parents
 void put(O obj, List<O> parents, List<O> children)
          Put an object along with parent and child lists.
 void remove(O parent, O child)
          Remove a parent-child relationship.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pmap

private final HashMap<O,List<O>> pmap
The data storage for parents


cmap

private final HashMap<O,List<O>> cmap
The data storage for children

Constructor Detail

HierarchyHashmapList

public HierarchyHashmapList()
Constructor

Method Detail

add

public void add(O parent,
                O child)
Description copied from interface: ModifiableHierarchy
Add a parent-child relationship.

Specified by:
add in interface ModifiableHierarchy<O>
Parameters:
parent - Parent
child - Child

remove

public void remove(O parent,
                   O child)
Description copied from interface: ModifiableHierarchy
Remove a parent-child relationship.

Specified by:
remove in interface ModifiableHierarchy<O>
Parameters:
parent - Parent
child - Child

put

public void put(O obj,
                List<O> parents,
                List<O> children)
Put an object along with parent and child lists.

Parameters:
obj - Object
parents - Parent list
children - Child list

numChildren

public int numChildren(O obj)
Description copied from interface: Hierarchy
Get number of children

Specified by:
numChildren in interface Hierarchy<O>
Parameters:
obj - object to get number of children for
Returns:
number of children

getChildren

public List<O> getChildren(O obj)
Description copied from interface: Hierarchy
Get children list. Resulting list MAY be modified. Result MAY be null, if the model is not hierarchical.

Specified by:
getChildren in interface Hierarchy<O>
Parameters:
obj - object to get children for
Returns:
list of children

iterDescendants

public IterableIterator<O> iterDescendants(O obj)
Description copied from interface: Hierarchy
Iterate descendants (recursive children)

Specified by:
iterDescendants in interface Hierarchy<O>
Parameters:
obj - object to get descendants for
Returns:
iterator for descendants

numParents

public int numParents(O obj)
Description copied from interface: Hierarchy
Get number of (direct) parents

Specified by:
numParents in interface Hierarchy<O>
Parameters:
obj - reference object
Returns:
number of parents

getParents

public List<O> getParents(O obj)
Description copied from interface: Hierarchy
Get parents list. Resulting list MAY be modified. Result MAY be null, if the model is not hierarchical.

Specified by:
getParents in interface Hierarchy<O>
Parameters:
obj - object to get parents for
Returns:
list of parents

iterAncestors

public IterableIterator<O> iterAncestors(O obj)
Description copied from interface: Hierarchy
Iterate ancestors (recursive parents)

Specified by:
iterAncestors in interface Hierarchy<O>
Parameters:
obj - object to get ancestors for
Returns:
iterator for ancestors

Release 0.4.0 (2011-09-20_1324)