@SuppressWarnings("unchecked")
private boolean btreeHas( BTree tree, V key, boolean isGreaterThan ) throws IOException
{
jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();
TupleBrowser browser = tree.browse( key );
if ( isGreaterThan )
{
return browser.getNext( tuple );
}
else
{
if ( browser.getPrevious( tuple ) )
{
return true;
}
else
{
/*
* getPrevious() above fails which means the browser has is
* before the first Tuple of the btree. A call to getNext()
* should work every time.
*/
browser.getNext( tuple );
/*
* Since the browser is positioned now on the Tuple with the
* smallest key we just need to check if it equals this key
* which is the only chance for returning true.