O
- Object type (arbitrary!)public class HashMapHierarchy<O> extends Object implements ModifiableHierarchy<O>
Modifier and Type | Class and Description |
---|---|
private class |
HashMapHierarchy.ItrAll
Iterator over all known elements, by insertion order.
|
private class |
HashMapHierarchy.ItrAnc
Iterator over all Ancestors.
|
private class |
HashMapHierarchy.ItrDesc
Iterator over all descendants.
|
protected static class |
HashMapHierarchy.Rec<O>
Hierarchy pointers for an object.
|
Hierarchy.Iter<O>
Modifier and Type | Field and Description |
---|---|
(package private) Object[] |
elems
All elements, in insertion order (and will not fail badly if concurrent
insertions happen).
|
private static Hierarchy.Iter<?> |
EMPTY_ITERATOR
Empty iterator.
|
private HashMap<O,HashMapHierarchy.Rec<O>> |
graph
Reference storage.
|
(package private) int |
numelems
Number of all elements.
|
Constructor and Description |
---|
HashMapHierarchy()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(O entry)
Add an entry (initializes data structures).
|
boolean |
add(O parent,
O child)
Add a parent-child relationship.
|
boolean |
contains(O object)
Check if an object is part of a hierarchy.
|
static <O> Hierarchy.Iter<O> |
emptyIterator()
Get an empty hierarchy iterator.
|
private HashMapHierarchy.Rec<O> |
getRec(O obj)
Get a record.
|
Hierarchy.Iter<O> |
iterAll()
Iterate over all members.
|
Hierarchy.Iter<O> |
iterAncestors(O obj)
Iterate ancestors (recursive parents)
|
Hierarchy.Iter<O> |
iterAncestorsSelf(O obj)
Iterate ancestors (recursive parents) and self.
|
Hierarchy.Iter<O> |
iterChildren(O obj)
Iterate over the (direct) children.
|
Hierarchy.Iter<O> |
iterChildrenReverse(O obj)
Iterate over the (direct) children in reverse order.
|
Hierarchy.Iter<O> |
iterDescendants(O obj)
Iterate descendants (recursive children)
|
Hierarchy.Iter<O> |
iterDescendantsSelf(O obj)
Iterate descendants (recursive children) and self.
|
Hierarchy.Iter<O> |
iterParents(O obj)
Iterate over the (direct) parents.
|
Hierarchy.Iter<O> |
iterParentsReverse(O obj)
Iterate over the (direct) parents in reverse order.
|
int |
numChildren(O obj)
Get number of children
|
int |
numParents(O obj)
Get number of (direct) parents
|
private void |
putRec(O obj,
HashMapHierarchy.Rec<O> rec)
Put a record.
|
boolean |
remove(O entry)
Remove an entry and all its parent-child relationships.
|
boolean |
remove(O parent,
O child)
Remove a parent-child relationship.
|
private void |
removeRec(O obj)
Remove a record.
|
boolean |
removeSubtree(O entry)
Remove an entry and it's whole subtree (unless the elements are reachable
by a different path!)
|
int |
size()
Total size - number of objects contained.
|
private final HashMap<O,HashMapHierarchy.Rec<O>> graph
Object[] elems
int numelems
private static final Hierarchy.Iter<?> EMPTY_ITERATOR
public boolean contains(O object)
Hierarchy
public int size()
Hierarchy
public boolean add(O parent, O child)
ModifiableHierarchy
add
in interface ModifiableHierarchy<O>
parent
- Parentchild
- Childtrue
if changedpublic boolean add(O entry)
ModifiableHierarchy
add
in interface ModifiableHierarchy<O>
entry
- Entrytrue
if changedpublic boolean remove(O parent, O child)
ModifiableHierarchy
remove
in interface ModifiableHierarchy<O>
parent
- Parentchild
- Childtrue
if changedpublic boolean remove(O entry)
ModifiableHierarchy
remove
in interface ModifiableHierarchy<O>
entry
- Entrytrue
if changedpublic boolean removeSubtree(O entry)
ModifiableHierarchy
removeSubtree
in interface ModifiableHierarchy<O>
entry
- Entrytrue
if changedpublic int numChildren(O obj)
Hierarchy
numChildren
in interface Hierarchy<O>
obj
- object to get number of children forpublic Hierarchy.Iter<O> iterChildren(O obj)
Hierarchy
iterChildren
in interface Hierarchy<O>
obj
- object to get children forpublic Hierarchy.Iter<O> iterChildrenReverse(O obj)
Hierarchy
iterChildrenReverse
in interface Hierarchy<O>
obj
- object to get children forpublic Hierarchy.Iter<O> iterDescendants(O obj)
Hierarchy
iterDescendants
in interface Hierarchy<O>
obj
- object to get descendants forpublic Hierarchy.Iter<O> iterDescendantsSelf(O obj)
Hierarchy
iterDescendantsSelf
in interface Hierarchy<O>
obj
- object to get descendants forpublic int numParents(O obj)
Hierarchy
numParents
in interface Hierarchy<O>
obj
- reference objectpublic Hierarchy.Iter<O> iterParents(O obj)
Hierarchy
iterParents
in interface Hierarchy<O>
obj
- object to get parents forpublic Hierarchy.Iter<O> iterParentsReverse(O obj)
Hierarchy
iterParentsReverse
in interface Hierarchy<O>
obj
- object to get parents forpublic Hierarchy.Iter<O> iterAncestors(O obj)
Hierarchy
iterAncestors
in interface Hierarchy<O>
obj
- object to get ancestors forpublic Hierarchy.Iter<O> iterAncestorsSelf(O obj)
Hierarchy
iterAncestorsSelf
in interface Hierarchy<O>
obj
- object to get ancestors forpublic Hierarchy.Iter<O> iterAll()
Hierarchy
private HashMapHierarchy.Rec<O> getRec(O obj)
obj
- Keyprivate void putRec(O obj, HashMapHierarchy.Rec<O> rec)
obj
- Keyrec
- Recordprivate void removeRec(O obj)
obj
- Keypublic static <O> Hierarchy.Iter<O> emptyIterator()
Copyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.