com.bigdata.btree
Class BTree.Stack

java.lang.Object
  extended by com.bigdata.btree.BTree.Stack
Enclosing class:
BTree

protected static class BTree.Stack
extends Object

A simple stack based on an array used to maintain hard references for the parent Nodes in the BTree.LeafCursor. This class is optimized for light-weight push/pop and copy operations. In particular, the copy operation is used to support atomic state changes for BTree.LeafCursor.prior() and BTree.LeafCursor.next().

Author:
Bryan Thompson

Constructor Summary
BTree.Stack()
          Stack with initial capacity of 10.
BTree.Stack(int capacity)
           
 
Method Summary
 int capacity()
          The size of the backing array.
 void clear()
          Clear the stack.
 void copyFrom(BTree.Stack src)
          Replace the state of this BTree.Stack with the state of the source BTree.Stack.
 Node peek()
          Return the element on the top of the stack.
 Node pop()
          Pop an element off of the stack.
 void push(Node item)
          Push an element onto the stack.
 int size()
          The #of elements on the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BTree.Stack

public BTree.Stack()
Stack with initial capacity of 10.

Note: The initial capacity is a relatively small since a B+Tree of depth 10 will have a very large number of tuples even with a small branching factor.


BTree.Stack

public BTree.Stack(int capacity)
Method Detail

capacity

public final int capacity()
The size of the backing array.


size

public final int size()
The #of elements on the stack.


push

public void push(Node item)
Push an element onto the stack.

Parameters:
item - The element (required).

pop

public Node pop()
Pop an element off of the stack.

Returns:
The element that was on the top of the stack.
Throws:
IllegalStateException - if the stack is empty.

peek

public Node peek()
Return the element on the top of the stack.

Throws:
IllegalStateException - if the stack is empty.

copyFrom

public void copyFrom(BTree.Stack src)
Replace the state of this BTree.Stack with the state of the source BTree.Stack.

Parameters:
src - The source BTree.Stack.

clear

public void clear()
Clear the stack.



Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.