-
Notifications
You must be signed in to change notification settings - Fork 1
/
FencePointer.cpp
49 lines (36 loc) · 1.05 KB
/
FencePointer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// Created by Stathis on 3/11/2019.
//
#include <cstdio>
#include "FencePointer.h"
#include <iostream>
using namespace std;
//-------------------- Constructor --------------------
FencePointer::FencePointer(int low, int high) :
lowest(low), highest(high) {}
//-------------------- Getters --------------------
int FencePointer::getLowest() { return this->lowest; }
int FencePointer::getHighest() { return this->highest; }
//-------------------- Setters --------------------
void FencePointer::setLowest(int newLow) {
this->lowest = newLow;
}
void FencePointer::setHighest(int newHigh) {
this->highest = newHigh;
}
void FencePointer::setPointers(int low, int high) {
this->lowest = low;
this->highest = high;
}
//-------------------- Range checks --------------------
int FencePointer::isInRange(int query) {
if ((query >= lowest) && (query <= highest))
return 0;
else if (query > highest)
return 1;
else
return -1;
}
int FencePointer::rangeOverlaps(int low, int high) {
return ((low <= highest) && (high >= lowest));
}