in mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java [472:529]
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 values
ParentPos<K, V> parentPos = stack[depth];
if ( parentPos.page == null )
{
// Empty BTree, get out
return false;
}
if ( parentPos.pos > 0 )
{
// get out, we have values on the left
return true;
}
else
{
// Check that we are not before the first value
if ( parentPos.pos == BEFORE_FIRST )
{
return false;
}
// Check if we have some more value
if ( parentPos.valueCursor.hasPrev() )
{
return true;
}
// Ok, here, we have reached the first value in the leaf. We have to go up and
// see if we have some remaining values
int currentDepth = depth - 1;
while ( currentDepth >= 0 )
{
parentPos = stack[currentDepth];
if ( parentPos.pos > 0 )
{
// The parent has some remaining values on the right, get out
return true;
}
else
{
currentDepth--;
}
}
return false;
}
}