public class Stack
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
Stack.Entry |
Modifier and Type | Field and Description |
---|---|
private long |
lastHandle |
private Heap |
stack |
Constructor and Description |
---|
Stack(java.io.File stackFile)
create a new stack object.
|
Modifier and Type | Method and Description |
---|---|
Stack.Entry |
bot()
return the bottom element of the stack.
|
void |
clear()
clear the stack content
|
void |
close()
close the stack file and write a handle index
|
void |
finalize() |
byte[] |
get(long handle)
get an element from the stack using the handle
|
java.util.Iterator<java.lang.Long> |
handles()
Iterate all handles from the stack as Long numbers
|
private long |
nextHandle()
create a new time handle.
|
private Stack.Entry |
po(byte[] k,
boolean remove) |
Stack.Entry |
pop()
remove the top element from the stack
|
Stack.Entry |
pot()
remove the bottom element from the stack
|
long |
push(byte[] b)
push a new element on the top of the stack
|
protected void |
push(Stack.Entry e)
push a new element on the top of the stack using a entry object
this is only useful for internal processes where a special handle
is created
|
byte[] |
remove(long handle)
remove an element from the stack using the entry handle
|
int |
size()
get the size of a stack
|
Stack.Entry |
top()
return the top element of the stack.
|
private final Heap stack
private long lastHandle
public Stack(java.io.File stackFile) throws java.io.IOException
stackFile
- java.io.IOException
public void clear() throws java.io.IOException
java.io.IOException
private long nextHandle()
public java.util.Iterator<java.lang.Long> handles() throws java.io.IOException
java.io.IOException
public int size()
public long push(byte[] b) throws java.io.IOException, SpaceExceededException
b
- the new stack elementjava.io.IOException
SpaceExceededException
protected void push(Stack.Entry e) throws java.io.IOException, SpaceExceededException
b
- the new stack elementjava.io.IOException
SpaceExceededException
public byte[] get(long handle) throws java.io.IOException, SpaceExceededException
handle
- java.io.IOException
SpaceExceededException
public byte[] remove(long handle) throws java.io.IOException, SpaceExceededException
handle
- java.io.IOException
SpaceExceededException
public Stack.Entry pop() throws java.io.IOException
java.io.IOException
public Stack.Entry top() throws java.io.IOException
java.io.IOException
public Stack.Entry pot() throws java.io.IOException
java.io.IOException
public Stack.Entry bot() throws java.io.IOException
java.io.IOException
private Stack.Entry po(byte[] k, boolean remove) throws java.io.IOException
java.io.IOException
public void close()
public void finalize()
finalize
in class java.lang.Object