Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions IntervalTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
#include <algorithm>
#include <iostream>


template <class T, typename K = int>
template <class T, typename K = std::size_t>
class Interval {
public:
K start;
Expand All @@ -20,12 +19,12 @@ class Interval {
};

template <class T, typename K>
int intervalStart(const Interval<T,K>& i) {
K intervalStart(const Interval<T,K>& i) {
return i.start;
}

template <class T, typename K>
int intervalStop(const Interval<T,K>& i) {
K intervalStop(const Interval<T,K>& i) {
return i.stop;
}

Expand All @@ -35,15 +34,15 @@ template <class T, typename K>
return out;
}

template <class T, typename K = int>
template <class T, typename K = std::size_t>
class IntervalStartSorter {
public:
bool operator() (const Interval<T,K>& a, const Interval<T,K>& b) {
return a.start < b.start;
}
};

template <class T, typename K = int>
template <class T, typename K = std::size_t>
class IntervalTree {

public:
Expand All @@ -54,7 +53,7 @@ class IntervalTree {
intervalVector intervals;
intervalTree* left;
intervalTree* right;
int center;
K center;

IntervalTree<T,K>(void)
: left(NULL)
Expand Down Expand Up @@ -96,11 +95,11 @@ class IntervalTree {

IntervalTree<T,K>(
intervalVector& ivals,
unsigned int depth = 16,
unsigned int minbucket = 64,
int leftextent = 0,
int rightextent = 0,
unsigned int maxbucket = 512
std::size_t depth = 16,
std::size_t minbucket = 64,
K leftextent = 0,
K rightextent = 0,
std::size_t maxbucket = 512
)
: left(NULL)
, right(NULL)
Expand All @@ -117,9 +116,9 @@ class IntervalTree {
std::sort(ivals.begin(), ivals.end(), intervalStartSorter);
}

int leftp = 0;
int rightp = 0;
int centerp = 0;
K leftp = 0;
K rightp = 0;
K centerp = 0;

if (leftextent || rightextent) {
leftp = leftextent;
Expand Down