|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrangesearch.ref.RangeTree2DImpl
An implementation of a two-dimensional range tree, using a balanced binary tree as the primary structure and an array as the secondary structure.
Field Summary | |
protected jdsl.core.api.Comparator |
m_comp1
|
protected jdsl.core.api.Comparator |
m_comp2
|
protected jdsl.core.api.BinaryTree |
m_tree
|
Constructor Summary | |
RangeTree2DImpl()
|
Method Summary | |
protected int |
binarySearchAfter(jdsl.core.ref.ArraySequence s,
java.lang.Object obj,
int start,
int end)
Recursively finds the index into a sorted array of the first element greater than or equal to the given element. |
protected int |
binarySearchBefore(jdsl.core.ref.ArraySequence s,
java.lang.Object obj,
int start,
int end)
Recursively finds the index into a sorted array of the last element less than or equal to the given element. |
protected void |
buildRangeBounds(jdsl.core.api.Position subTreeRoot)
Extracts the minimum and maximum elements of the subtree and stores them as decorations with the string tags "min" and "max". |
protected void |
buildRangeSet(jdsl.core.api.Position subTreeRoot)
Recursively builds the secondary structure (a sorted array) at each internal node. |
protected void |
constructTree(jdsl.core.api.Position subTreeRoot,
jdsl.core.ref.ArraySequence s,
int start,
int end)
Recursively constructs a tree, expanding the given node to include the given subsequence of elements. |
protected void |
findAllocNode(jdsl.core.api.Position subTreeRoot,
jdsl.core.api.Sequence allocNodes,
java.lang.Object start,
java.lang.Object end)
Recursively searches the binary tree for allocation nodes. |
void |
initialize(jdsl.core.api.ObjectIterator oi,
jdsl.core.api.Comparator comp1,
jdsl.core.api.Comparator comp2)
Initializes the range tree to the given set of elements, with the given comparator. |
protected jdsl.core.api.Sequence |
mergeSortedArrays(jdsl.core.api.Sequence s1,
jdsl.core.api.Sequence s2)
Merges two sorted arrays together into another sorted array, as sorted by the secondary comparator. |
jdsl.core.api.ObjectIterator |
query(java.lang.Object start1,
java.lang.Object end1,
java.lang.Object start2,
java.lang.Object end2)
Queries the elements in the range tree with the given ranges. |
protected void |
queryAllocNode(jdsl.core.ref.ArraySequence s,
jdsl.core.api.Sequence retSeq,
java.lang.Object start,
java.lang.Object end)
Finds the nodes between start and end in the given sequence and appends them to the return sequence. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected jdsl.core.api.Comparator m_comp1
protected jdsl.core.api.Comparator m_comp2
protected jdsl.core.api.BinaryTree m_tree
Constructor Detail |
public RangeTree2DImpl()
Method Detail |
public void initialize(jdsl.core.api.ObjectIterator oi, jdsl.core.api.Comparator comp1, jdsl.core.api.Comparator comp2)
initialize
in interface RangeTree2D
oi
- an iterator over the elements to search.comp1
- the comparator for the primary structure (used for building
the binary tree).comp2
- the comparator for the secondary structure (used for
sorting the array.protected void constructTree(jdsl.core.api.Position subTreeRoot, jdsl.core.ref.ArraySequence s, int start, int end)
subTreeRoot
- the node to expand.s
- the sequence from which to extract elements.start
- the start index of the sequence to extract.end
- the end index of the sequence to extract.protected void buildRangeSet(jdsl.core.api.Position subTreeRoot)
subTreeRoot
- the node for which to build a secondary structure.protected jdsl.core.api.Sequence mergeSortedArrays(jdsl.core.api.Sequence s1, jdsl.core.api.Sequence s2)
s1
- the first array to merge.s2
- the second array to merge.
protected void buildRangeBounds(jdsl.core.api.Position subTreeRoot)
subTreeRoot
- the subtree on which to operate.public jdsl.core.api.ObjectIterator query(java.lang.Object start1, java.lang.Object end1, java.lang.Object start2, java.lang.Object end2)
query
in interface RangeTree2D
start1
- the starting element for the primary search range.end1
- the ending element for the primary search range.start2
- the starting element for the secondary search range.end2
- the ending element for the secondary search range.
protected void findAllocNode(jdsl.core.api.Position subTreeRoot, jdsl.core.api.Sequence allocNodes, java.lang.Object start, java.lang.Object end)
subTreeRoot
- the subtree to search.start
- the start of the primary search range.end
- the end of the primary search range.protected void queryAllocNode(jdsl.core.ref.ArraySequence s, jdsl.core.api.Sequence retSeq, java.lang.Object start, java.lang.Object end)
s
- the sequence to search.retSeq
- the return sequence to which allocation nodes are append.start
- the start bounds of the secondary search range.end
- the end bounds of the secondary search range.protected int binarySearchAfter(jdsl.core.ref.ArraySequence s, java.lang.Object obj, int start, int end)
s
- the sorted array to search.obj
- the element to search for.start
- the start index of the search.end
- the end index of the search.
protected int binarySearchBefore(jdsl.core.ref.ArraySequence s, java.lang.Object obj, int start, int end)
s
- the sorted array to search.obj
- the element to search for.start
- the start index of the search.end
- the end index of the search.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |