Commit 217bdf6d authored by Yoni Fogel's avatar Yoni Fogel

Closes 284

Linear time range tree implementation complete and passes all tests.

git-svn-id: file:///svn/tokudb@1778 c7de825b-a66e-492c-adef-691d508d4ae1
parent c6e67f9d
......@@ -6,7 +6,7 @@ LIBNAME=librangetree
OPTFLAGS = #-O2
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage
CFLAGS = -W -Wall -Werror -g -fPIC $(OPTFLAGS) $(GCOV_FLAGS)
CFLAGS = -W -Wall -Werror -g3 -ggdb3 -fPIC $(OPTFLAGS) $(GCOV_FLAGS)
CPPFLAGS = -I../../include -I../../newbrt
#CPPFLAGS += -D_GNU_SOURCE -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
......@@ -27,7 +27,7 @@ install: $(LIBNAMELINEAR).$(LIBEXT) $(LIBNAMELINEAR).a #$(LIBNAME).$(LIBEXT) $(L
cp $(LIBNAMELINEAR).a ../../lib
clean:
rm -rf $(LIBNAMELINEAR).$(LIBEXT) $(LIBNAMELINEAR)
rm -rf $(LIBNAMELINEAR).$(LIBEXT) $(LIBNAMELINEAR).a
rm -rf $(LIBNAME).$(LIBEXT) $(LIBNAME).a *.o *.gcno *.gcda *.gcov
cd tests;make clean
......
......@@ -78,15 +78,11 @@ static BOOL __toku_rt_overlap(toku_range_tree* tree,
tree->end_cmp(b->left, a->right) <= 0);
}
BOOL __toku_rt_exact(toku_range_tree* tree,
static BOOL __toku_rt_exact(toku_range_tree* tree,
toku_range* a, toku_range* b) {
assert(tree);
assert(a);
// assert(a->left);
// assert(a->right);
assert(b);
// assert(b->left);
// assert(b->right);
return (tree->end_cmp (a->left, b->left) == 0 &&
tree->end_cmp (a->right, b->right) == 0 &&
tree->data_cmp(a->data, b->data) == 0);
......@@ -174,7 +170,7 @@ int toku_rt_insert(toku_range_tree* tree, toku_range* range) {
}
r = __toku_rt_increase_capacity(tree, tree->numelements + 1);
if (r != 0) return r;
tree->ranges[++tree->numelements] = *range;
tree->ranges[tree->numelements++] = *range;
return 0;
}
......@@ -189,7 +185,7 @@ int toku_rt_delete(toku_range_tree* tree, toku_range* range) {
//EDOM case: Not Found
if (i == tree->numelements) return EDOM;
if (i < tree->numelements - 1) {
//juggle
tree->ranges[i] = tree->ranges[tree->numelements - 1];
}
__toku_rt_decrease_capacity(tree, --tree->numelements);
return 0;
......@@ -209,7 +205,7 @@ int toku_rt_predecessor (toku_range_tree* tree, void* point, toku_range* pred,
}
}
*wasfound = best != NULL;
pred = best;
if (best) *pred = *best;
return 0;
}
......@@ -227,7 +223,7 @@ int toku_rt_successor (toku_range_tree* tree, void* point, toku_range* succ,
}
}
*wasfound = best != NULL;
succ = best;
if (best) *succ = *best;
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment