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
fd3aa704
Commit
fd3aa704
authored
7 years ago
by
Christopher Schankula
Browse files
Options
Downloads
Patches
Plain Diff
add Bound and Range
parent
ec5372c0
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/sort/Bound.java
+5
-0
5 additions, 0 deletions
src/sort/Bound.java
src/sort/Range.java
+46
-0
46 additions, 0 deletions
src/sort/Range.java
with
51 additions
and
0 deletions
src/sort/Bound.java
0 → 100644
+
5
−
0
View file @
fd3aa704
package
sort
;
public
enum
Bound
{
LOWER
,
UPPER
,
LOWHIGH
,
ANY
;
}
This diff is collapsed.
Click to expand it.
src/sort/Range.java
0 → 100644
+
46
−
0
View file @
fd3aa704
package
sort
;
public
class
Range
<
Key
extends
Comparable
<
Key
>>
{
private
final
Bound
boundType
;
private
final
Key
lower
;
private
final
Key
upper
;
public
Range
(
Bound
bt
)
throws
Exception
{
if
(
bt
==
Bound
.
ANY
)
{
boundType
=
bt
;
lower
=
null
;
upper
=
null
;
}
else
throw
new
Exception
(
"Must provide ANY bound."
);
}
public
Range
(
Bound
bt
,
Key
upperOrLower
)
throws
Exception
{
if
(
bt
==
Bound
.
UPPER
)
{
upper
=
upperOrLower
;
lower
=
null
;
}
else
if
(
bt
==
Bound
.
LOWER
)
{
upper
=
upperOrLower
;
lower
=
null
;
}
else
throw
new
Exception
(
"Must provide UPPER OR LOWER bound."
);
boundType
=
bt
;
}
public
Range
(
Bound
bt
,
Key
lower
,
Key
upper
)
throws
Exception
{
if
(
bt
==
Bound
.
LOWHIGH
)
{
this
.
lower
=
lower
;
this
.
upper
=
upper
;
}
else
throw
new
Exception
(
"Must provide LOWHIGH bound."
);
this
.
boundType
=
bt
;
}
public
boolean
inBounds
(
Key
key
,
GeneralCompare
<
Key
>
gc
)
{
if
(
boundType
==
Bound
.
ANY
)
return
true
;
else
if
(
boundType
==
Bound
.
LOWER
)
return
gc
.
compare
(
lower
,
key
)
<=
0
;
else
if
(
boundType
==
Bound
.
UPPER
)
return
gc
.
compare
(
upper
,
key
)
>=
0
;
else
return
gc
.
compare
(
lower
,
key
)
<=
0
&&
gc
.
compare
(
upper
,
key
)
>=
0
;
}
}
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