#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#ifndef KEYRANGE_H
#define KEYRANGE_H
#include<ft/comparator.h>
namespacetoku{
// A keyrange has a left and right key as endpoints.
//
// When a keyrange is created it owns no memory, but when it copies
// or extends another keyrange, it copies memory as necessary. This
// means it is cheap in the common case.
classkeyrange{
public:
// effect: constructor that borrows left and right key pointers.
// no memory is allocated or copied.
voidcreate(constDBT*left_key,constDBT*right_key);
// effect: constructor that allocates and copies another keyrange's points.
voidcreate_copy(constkeyrange&range);
// effect: destroys the keyrange, freeing any allocated memory
voiddestroy(void);
// effect: extends the keyrange by choosing the leftmost and rightmost
// endpoints from this range and the given range.
// replaced keys in this range are freed, new keys are copied.
voidextend(comparator*cmp,constkeyrange&range);
// returns: the amount of memory this keyrange takes. does not account
// for point optimizations or malloc overhead.
uint64_tget_memory_size(void)const;
// returns: pointer to the left key of this range
constDBT*get_left_key(void)const;
// returns: pointer to the right key of this range
constDBT*get_right_key(void)const;
// two ranges are either equal, lt, gt, or overlapping
enumcomparison{
EQUALS,
LESS_THAN,
GREATER_THAN,
OVERLAPS
};
// effect: compares this range to the given range
// returns: LESS_THAN if given range is strictly to the left
// GREATER_THAN if given range is strictly to the right
// EQUALS if given range has the same left and right endpoints
// OVERLAPS if at least one of the given range's endpoints falls