O
- Object type (arbitrary!)public class HierarchyHashmapList<O> extends Object implements ModifiableHierarchy<O>
Modifier and Type | Class and Description |
---|---|
private class |
HierarchyHashmapList.ItrAnc
Iterator over all Ancestors.
|
private class |
HierarchyHashmapList.ItrDesc
Iterator to collect into the descendants.
|
Modifier and Type | Field and Description |
---|---|
private HashMap<O,List<O>> |
cmap
The data storage for children
|
private HashMap<O,List<O>> |
pmap
The data storage for parents
|
Constructor and Description |
---|
HierarchyHashmapList()
Constructor
|
Modifier and Type | Method and Description |
---|---|
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.
|
Iterator<O> |
iterAncestors(O obj)
Iterate ancestors (recursive parents)
|
Iterator<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.
|
public void add(O parent, O child)
ModifiableHierarchy
add
in interface ModifiableHierarchy<O>
parent
- Parentchild
- Childpublic void remove(O parent, O child)
ModifiableHierarchy
remove
in interface ModifiableHierarchy<O>
parent
- Parentchild
- Childpublic void put(O obj, List<O> parents, List<O> children)
obj
- Objectparents
- Parent listchildren
- Child listpublic int numChildren(O obj)
Hierarchy
numChildren
in interface Hierarchy<O>
obj
- object to get number of children forpublic List<O> getChildren(O obj)
Hierarchy
getChildren
in interface Hierarchy<O>
obj
- object to get children forpublic Iterator<O> iterDescendants(O obj)
Hierarchy
iterDescendants
in interface Hierarchy<O>
obj
- object to get descendants forpublic int numParents(O obj)
Hierarchy
numParents
in interface Hierarchy<O>
obj
- reference objectpublic List<O> getParents(O obj)
Hierarchy
getParents
in interface Hierarchy<O>
obj
- object to get parents for