Skip to content

Commit

Permalink
More cleanup. malloc=>new.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenFrantzDale committed Oct 3, 2014
1 parent fc8b828 commit 323ac8b
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions IntervalTree.h
Expand Up @@ -62,36 +62,33 @@ class IntervalTree {
, center(0)
{ }

IntervalTree<T,K>(const intervalTree& other) {
IntervalTree<T,K>(const intervalTree& other)
: left(NULL)
, right(NULL)
{
center = other.center;
intervals = other.intervals;
if (other.left) {
left = (intervalTree*) malloc(sizeof(intervalTree));
*left = *other.left;
} else {
left = NULL;
left = new intervalTree(*other.left);
}
if (other.right) {
right = new intervalTree();
*right = *other.right;
} else {
right = NULL;
right = new intervalTree(*other.right);
}
}

IntervalTree<T,K>& operator=(const intervalTree& other) {
center = other.center;
intervals = other.intervals;
if (other.left) {
left = new intervalTree();
*left = *other.left;
left = new intervalTree(*other.left);
} else {
if (left) delete left;
left = NULL;
}
if (other.right) {
right = new intervalTree();
*right = *other.right;
right = new intervalTree(*other.right);
} else {
if (right) delete right;
right = NULL;
}
return *this;
Expand All @@ -112,12 +109,12 @@ class IntervalTree {
--depth;
IntervalStartSorter<T,K> intervalStartSorter;
if (depth == 0 || (ivals.size() < minbucket && ivals.size() < maxbucket)) {
sort(ivals.begin(), ivals.end(), intervalStartSorter);
std::sort(ivals.begin(), ivals.end(), intervalStartSorter);
intervals = ivals;
} else {
if (leftextent == 0 && rightextent == 0) {
// sort intervals by start
sort(ivals.begin(), ivals.end(), intervalStartSorter);
std::sort(ivals.begin(), ivals.end(), intervalStartSorter);
}

int leftp = 0;
Expand Down

0 comments on commit 323ac8b

Please sign in to comment.