O
- Object type (arbitrary!)public class HashMapHierarchy<O> extends java.lang.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.
|
Modifier and Type | Field and Description |
---|---|
(package private) java.lang.Object[] |
elems
All elements, in insertion order (and will not fail badly if concurrent
insertions happen).
|
private java.util.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.
|
private HashMapHierarchy.Rec<O> |
getRec(O obj)
Get a record.
|
It<O> |
iterAll()
Iterate over all members.
|
It<O> |
iterAncestors(O obj)
Iterate ancestors (recursive parents)
|
It<O> |
iterAncestorsSelf(O obj)
Iterate ancestors (recursive parents) and self.
|
It<O> |
iterChildren(O obj)
Iterate over the (direct) children.
|
It<O> |
iterChildrenReverse(O obj)
Iterate over the (direct) children in reverse order.
|
It<O> |
iterDescendants(O obj)
Iterate descendants (recursive children)
|
It<O> |
iterDescendantsSelf(O obj)
Iterate descendants (recursive children) and self.
|
It<O> |
iterParents(O obj)
Iterate over the (direct) parents.
|
It<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 java.util.HashMap<O,HashMapHierarchy.Rec<O>> graph
java.lang.Object[] elems
int numelems
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 It<O> iterChildren(O obj)
Hierarchy
iterChildren
in interface Hierarchy<O>
obj
- object to get children forpublic It<O> iterChildrenReverse(O obj)
Hierarchy
iterChildrenReverse
in interface Hierarchy<O>
obj
- object to get children forpublic It<O> iterDescendants(O obj)
Hierarchy
iterDescendants
in interface Hierarchy<O>
obj
- object to get descendants forpublic It<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 It<O> iterParents(O obj)
Hierarchy
iterParents
in interface Hierarchy<O>
obj
- object to get parents forpublic It<O> iterParentsReverse(O obj)
Hierarchy
iterParentsReverse
in interface Hierarchy<O>
obj
- object to get parents forpublic It<O> iterAncestors(O obj)
Hierarchy
iterAncestors
in interface Hierarchy<O>
obj
- object to get ancestors forpublic It<O> iterAncestorsSelf(O obj)
Hierarchy
iterAncestorsSelf
in interface Hierarchy<O>
obj
- object to get ancestors forpublic It<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
- KeyCopyright © 2019 ELKI Development Team. License information.