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
a0ae6ae9
Commit
a0ae6ae9
authored
7 years ago
by
Ray Liu
Browse files
Options
Downloads
Patches
Plain Diff
Finished helper function and also removed year, month, day from Recrod.java
parent
b02f24ed
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/data/Record.java
+2
-34
2 additions, 34 deletions
src/data/Record.java
src/sort/RangeHelper.java
+42
-10
42 additions, 10 deletions
src/sort/RangeHelper.java
with
44 additions
and
44 deletions
src/data/Record.java
+
2
−
34
View file @
a0ae6ae9
...
...
@@ -9,9 +9,7 @@ public class Record implements Comparable<Record> {
private
final
float
latitude
;
private
final
float
longitude
;
private
final
int
year
;
private
final
int
month
;
private
final
int
day
;
private
final
Date
recDate
;
...
...
@@ -27,9 +25,7 @@ public class Record implements Comparable<Record> {
this
.
latitude
=
latitude
;
this
.
longitude
=
longitude
;
this
.
year
=
year
;
this
.
month
=
month
;
this
.
day
=
day
;
this
.
recDate
=
new
Date
(
year
,
month
,
day
);
}
...
...
@@ -83,34 +79,6 @@ public class Record implements Comparable<Record> {
return
longitude
;
}
/**
* Gets year of the record
*
* @return The year of the record
*/
public
int
getYear
()
{
return
year
;
}
/**
* Gets month of the record
*
* @return The month of the record
*/
public
int
getMonth
()
{
return
month
;
}
/**
* Gets day of the record
*
* @return The day of the record
*/
public
int
getDay
()
{
return
day
;
}
/**
* Gets date of the record
*
...
...
This diff is collapsed.
Click to expand it.
src/sort/RangeHelper.java
+
42
−
10
View file @
a0ae6ae9
package
sort
;
import
data.Record
;
import
data.Date
;
public
class
RangeHelper
{
public
static
GeneralRange
<
Record
>
taxonID
(
Bound
boundtype
)
{
if
(
boundtype
==
Bound
.
ANY
)
{
...
...
@@ -17,11 +17,11 @@ public class RangeHelper {
return
range
;
}
else
if
(
boundtype
==
Bound
.
UPPER
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getTaxonId
()
>
bound
?
0
:
1
;
GeneralRange
<
Record
>
range
=
p
->
p
.
getTaxonId
()
>
bound
?
0
:
-
1
;
return
range
;
}
else
if
(
boundtype
==
Bound
.
EQUALS
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getTaxonId
()
==
bound
?
0
:
1
;
GeneralRange
<
Record
>
range
=
p
->
p
.
getTaxonId
()
-
bound
;
return
range
;
}
else
return
null
;
...
...
@@ -43,23 +43,23 @@ public class RangeHelper {
else
return
null
;
}
public
static
GeneralRange
<
Record
>
longitude
(
Bound
boundtype
,
in
t
bound
)
{
public
static
GeneralRange
<
Record
>
longitude
(
Bound
boundtype
,
floa
t
bound
)
{
if
(
boundtype
==
Bound
.
LOWER
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getLongitude
()
<
bound
?
0
:
1
;
return
range
;
}
else
if
(
boundtype
==
Bound
.
UPPER
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getLongitude
()
>
bound
?
0
:
1
;
GeneralRange
<
Record
>
range
=
p
->
p
.
getLongitude
()
>
bound
?
0
:
-
1
;
return
range
;
}
else
if
(
boundtype
==
Bound
.
EQUALS
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getLongitude
()
==
bound
?
0
:
1
;
GeneralRange
<
Record
>
range
=
p
->
Float
.
compare
(
p
.
getLongitude
()
,
bound
)
;
return
range
;
}
else
return
null
;
}
public
static
GeneralRange
<
Record
>
longitude
(
Bound
boundtype
,
in
t
leftbound
,
in
t
rightbound
)
{
public
static
GeneralRange
<
Record
>
longitude
(
Bound
boundtype
,
floa
t
leftbound
,
floa
t
rightbound
)
{
if
(
boundtype
==
Bound
.
LOWHIGH
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getLongitude
()
<
leftbound
?
-
1
:
(
p
.
getLongitude
()
>
rightbound
?
1
:
0
);
return
range
;
...
...
@@ -75,17 +75,17 @@ public class RangeHelper {
else
return
null
;
}
public
static
GeneralRange
<
Record
>
latitude
(
Bound
boundtype
,
in
t
bound
)
{
public
static
GeneralRange
<
Record
>
latitude
(
Bound
boundtype
,
floa
t
bound
)
{
if
(
boundtype
==
Bound
.
LOWER
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getLatitude
()
<
bound
?
0
:
1
;
return
range
;
}
else
if
(
boundtype
==
Bound
.
UPPER
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getLatitude
()
>
bound
?
0
:
1
;
GeneralRange
<
Record
>
range
=
p
->
p
.
getLatitude
()
>
bound
?
0
:
-
1
;
return
range
;
}
else
if
(
boundtype
==
Bound
.
EQUALS
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getLatitude
()
==
bound
?
0
:
1
;
GeneralRange
<
Record
>
range
=
p
->
Float
.
compare
(
p
.
getLatitude
()
,
bound
)
;
return
range
;
}
else
return
null
;
...
...
@@ -98,4 +98,36 @@ public class RangeHelper {
}
else
return
null
;
}
public
static
GeneralRange
<
Record
>
date
(
Bound
boundtype
)
{
if
(
boundtype
==
Bound
.
ANY
)
{
GeneralRange
<
Record
>
range
=
p
->
0
;
return
range
;
}
else
return
null
;
}
public
static
GeneralRange
<
Record
>
date
(
Bound
boundtype
,
Date
bound
)
{
if
(
boundtype
==
Bound
.
LOWER
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getDate
().
compareTo
(
bound
)
==
-
1
?
0
:
1
;
return
range
;
}
else
if
(
boundtype
==
Bound
.
UPPER
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getDate
().
compareTo
(
bound
)
==
1
?
0
:
-
1
;
return
range
;
}
else
if
(
boundtype
==
Bound
.
EQUALS
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getDate
().
compareTo
(
bound
)
;
return
range
;
}
else
return
null
;
}
public
static
GeneralRange
<
Record
>
date
(
Bound
boundtype
,
Date
leftbound
,
Date
rightbound
)
{
if
(
boundtype
==
Bound
.
LOWHIGH
)
{
GeneralRange
<
Record
>
range
=
p
->
p
.
getDate
().
compareTo
(
leftbound
)
==
-
1
?
-
1
:
(
p
.
getDate
().
compareTo
(
rightbound
)
==
1
?
1
:
0
);
return
range
;
}
else
return
null
;
}
}
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