in mavibot/src/main/java/org/apache/directory/mavibot/btree/KeyCursor.java [350:406]
public boolean hasPrev() throws EndOfFileExceededException, IOException
{
// First check that we have elements in the BTree
if ( ( stack == null ) || ( stack.length == 0 ) )
{
return false;
}
// Take the leaf and check if we have no mare keys
ParentPos<K, K> parentPos = stack[depth];
if ( parentPos.page == null )
{
// Empty BTree, get out
return false;
}
if ( parentPos.pos > 0 )
{
// get out, we have keys on the left
return true;
}
else
{
// Check that we are not before the first key
if ( parentPos.pos == BEFORE_FIRST )
{
return false;
}
if ( parentPos.pos == AFTER_LAST )
{
return true;
}
// Ok, here, we have reached the first key in the leaf. We have to go up and
// see if we have some remaining keys
int currentDepth = depth - 1;
while ( currentDepth >= 0 )
{
parentPos = stack[currentDepth];
if ( parentPos.pos > 0 )
{
// The parent has some remaining keys on the right, get out
return true;
}
else
{
currentDepth--;
}
}
return false;
}
}