Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2XB3FinalProject
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Schankula
2XB3FinalProject
Commits
9a7aad79
Commit
9a7aad79
authored
7 years ago
by
Christopher Schankula
Browse files
Options
Downloads
Patches
Plain Diff
partial comments on KDT module
parent
7a8710e8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/biotree/Data.java
+11
-0
11 additions, 0 deletions
src/biotree/Data.java
src/sort/KDT.java
+19
-0
19 additions, 0 deletions
src/sort/KDT.java
with
30 additions
and
0 deletions
src/biotree/Data.java
0 → 100644
+
11
−
0
View file @
9a7aad79
package
biotree
;
import
sort.KDT
;
public
class
Data
{
KDT
data
=
new
KDT
<
Integer
>();
public
static
void
initialize
(
Record
rec
)
{
}
}
This diff is collapsed.
Click to expand it.
src/sort/KDT.java
+
19
−
0
View file @
9a7aad79
...
...
@@ -61,6 +61,15 @@ public class KDT<KeyVal extends Comparable<KeyVal>> {
}
}
/**
* Create a new KD-tree from an array of key-value paired objects.
* @param axes A sequence of k GeneralCompare functions which compare based on each of the k axes.
* For example, to order a point based on x in the first axis and y in the second, the two
* GeneralCompares should correspond to x and y respectively. The length k of this list also
* defines the number of axes contained within the tree (the number of unique values on which
* to index the data).
* @param keyvals An array of key-value pairs to be inserted into the tree initially.
*/
public
KDT
(
ArrayList
<
GeneralCompare
<
KeyVal
>>
axes
,
Comparable
<
KeyVal
>[]
keyvals
)
{
this
.
axes
=
axes
;
root
=
buildTree
(
keyvals
,
0
,
keyvals
.
length
-
1
,
0
);
...
...
@@ -85,6 +94,12 @@ public class KDT<KeyVal extends Comparable<KeyVal>> {
return
newNode
;
}
/**
* Range search by providing k GeneralRange functions.
* @param range An ArrayList sequence of k GeneralRange functions for searching on
* each of the k axes. Must equal the number of axes used in the current tree.
* @return An Iterable object of all results found within the range specified.
*/
public
Iterable
<
KeyVal
>
rangeSearch
(
ArrayList
<
GeneralRange
<
KeyVal
>>
range
){
ArrayList
<
KeyVal
>
result
=
new
ArrayList
<
KeyVal
>();
rangeSearch
(
root
,
range
,
result
,
0
);
...
...
@@ -138,6 +153,10 @@ public class KDT<KeyVal extends Comparable<KeyVal>> {
else
return
x
.
n
;
}
/**
* Get the number of axes in this tree.
* @return The number of axes, k, in the current tree.
*/
public
int
getK
()
{
return
axes
.
size
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment