@InterfaceAudience.Private public static class AvlUtil.AvlTree extends Object
Constructor and Description |
---|
AvlTree() |
Modifier and Type | Method and Description |
---|---|
private static <TNode extends AvlUtil.AvlNode> |
balance(TNode p) |
private static <TNode extends AvlUtil.AvlNode> |
balanceFactor(TNode node) |
private static <TNode extends AvlUtil.AvlNode> |
fixHeight(TNode node) |
static <TNode extends AvlUtil.AvlNode> |
get(TNode root,
Object key,
AvlUtil.AvlKeyComparator<TNode> keyComparator) |
static <TNode extends AvlUtil.AvlNode> |
getFirst(TNode root) |
static <TNode extends AvlUtil.AvlNode> |
getLast(TNode root) |
private static <TNode extends AvlUtil.AvlNode> |
height(TNode node) |
static <TNode extends AvlUtil.AvlNode> |
insert(TNode root,
Object key,
AvlUtil.AvlKeyComparator<TNode> keyComparator,
AvlUtil.AvlInsertOrReplace<TNode> insertOrReplace)
Insert a node into the tree.
|
static <TNode extends AvlUtil.AvlNode> |
insert(TNode root,
TNode node)
Insert a node into the tree.
|
static <TNode extends AvlUtil.AvlNode> |
remove(TNode root,
Object key,
AvlUtil.AvlKeyComparator<TNode> keyComparator)
Removes the node matching the specified key from the tree
|
static <TNode extends AvlUtil.AvlNode> |
remove(TNode root,
Object key,
AvlUtil.AvlKeyComparator<TNode> keyComparator,
AtomicBoolean removed)
Removes the node matching the specified key from the tree
|
private static <TNode extends AvlUtil.AvlNode> |
removeMin(TNode p) |
private static <TNode extends AvlUtil.AvlNode> |
rotateLeft(TNode q) |
private static <TNode extends AvlUtil.AvlNode> |
rotateRight(TNode p) |
static <TNode extends AvlUtil.AvlNode> |
visit(TNode root,
AvlUtil.AvlNodeVisitor<TNode> visitor)
Visit each node of the tree
|
public AvlTree()
public static <TNode extends AvlUtil.AvlNode> TNode get(TNode root, Object key, AvlUtil.AvlKeyComparator<TNode> keyComparator)
root
- the current root of the treekey
- the key for the node we are trying to findkeyComparator
- the comparator to use to match node and keypublic static <TNode extends AvlUtil.AvlNode> TNode getFirst(TNode root)
root
- the current root of the treepublic static <TNode extends AvlUtil.AvlNode> TNode getLast(TNode root)
root
- the current root of the treepublic static <TNode extends AvlUtil.AvlNode> TNode insert(TNode root, TNode node)
root
- the current root of the treenode
- the node to insertpublic static <TNode extends AvlUtil.AvlNode> TNode insert(TNode root, Object key, AvlUtil.AvlKeyComparator<TNode> keyComparator, AvlUtil.AvlInsertOrReplace<TNode> insertOrReplace)
root
- the current root of the treekey
- the key for the node we are trying to insertkeyComparator
- the comparator to use to match node and keyinsertOrReplace
- the class to use to insert or replace the nodeprivate static <TNode extends AvlUtil.AvlNode> TNode removeMin(TNode p)
public static <TNode extends AvlUtil.AvlNode> TNode remove(TNode root, Object key, AvlUtil.AvlKeyComparator<TNode> keyComparator)
root
- the current root of the treekey
- the key for the node we are trying to findkeyComparator
- the comparator to use to match node and keypublic static <TNode extends AvlUtil.AvlNode> TNode remove(TNode root, Object key, AvlUtil.AvlKeyComparator<TNode> keyComparator, AtomicBoolean removed)
root
- the current root of the treekey
- the key for the node we are trying to findkeyComparator
- the comparator to use to match node and keyremoved
- will be set to true if the node was found and removed, otherwise falsepublic static <TNode extends AvlUtil.AvlNode> void visit(TNode root, AvlUtil.AvlNodeVisitor<TNode> visitor)
root
- the current root of the treevisitor
- the AvlNodeVisitor instanceprivate static <TNode extends AvlUtil.AvlNode> TNode balance(TNode p)
private static <TNode extends AvlUtil.AvlNode> TNode rotateRight(TNode p)
private static <TNode extends AvlUtil.AvlNode> TNode rotateLeft(TNode q)
private static <TNode extends AvlUtil.AvlNode> void fixHeight(TNode node)
private static <TNode extends AvlUtil.AvlNode> int height(TNode node)
private static <TNode extends AvlUtil.AvlNode> int balanceFactor(TNode node)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.