Class Oscilloscope.IntegerFiFoCircularStack
- java.lang.Object
-
- org.eclipse.nebula.widgets.oscilloscope.multichannel.Oscilloscope.IntegerFiFoCircularStack
-
- Enclosing class:
- Oscilloscope
public class Oscilloscope.IntegerFiFoCircularStack extends java.lang.ObjectThe stack can hold a limited number of values but will never overflow. Think of the stack as a tube with a given length. If you push too many values in, the oldest will be pushed out at the end.
-
-
Field Summary
Fields Modifier and Type Field Description private intbottomprivate intcapacityprivate int[]stackprivate intstoredValuesprivate inttop
-
Constructor Summary
Constructors Constructor Description IntegerFiFoCircularStack(int capacity)Creates a stack with the indicated capacity.IntegerFiFoCircularStack(int capacity, Oscilloscope.IntegerFiFoCircularStack oldStack)Creates stack with the indicated capacity and copies the old stack into the new stack and the old stack will be empty after this action.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the stack.intgetCapacity()intgetLoad()booleanisEmpty()booleanisFull()intpeek(int valueIfEmpty)Returns the oldest value from the stack without removing the value from the stack.intpop(int valueIfEmpty)Returns the oldest value from the stack.intpopNegate(int valueIfEmpty)Returns the oldest value from the stack and negates the value.voidpush(int value)Puts a value on the stack.
-
-
-
Constructor Detail
-
IntegerFiFoCircularStack
public IntegerFiFoCircularStack(int capacity)
Creates a stack with the indicated capacity.- Parameters:
capacity- must be greater than 1
-
IntegerFiFoCircularStack
public IntegerFiFoCircularStack(int capacity, Oscilloscope.IntegerFiFoCircularStack oldStack)Creates stack with the indicated capacity and copies the old stack into the new stack and the old stack will be empty after this action.- Parameters:
capacity- must be greater than 1oldStack-
-
-
Method Detail
-
clear
public void clear()
Clears the stack.
-
getCapacity
public int getCapacity()
-
getLoad
public int getLoad()
- Returns:
- boolean
-
isEmpty
public boolean isEmpty()
- Returns:
- boolean
-
isFull
public boolean isFull()
- Returns:
- boolean
-
peek
public int peek(int valueIfEmpty)
Returns the oldest value from the stack without removing the value from the stack. Returns the supplied entry if the stack is empty.- Parameters:
valueIfEmpty-- Returns:
- int
-
pop
public int pop(int valueIfEmpty)
Returns the oldest value from the stack. Returns the supplied entry if the stack is empty.- Parameters:
valueIfEmpty-- Returns:
- int
-
popNegate
public int popNegate(int valueIfEmpty)
Returns the oldest value from the stack and negates the value. Returns the supplied entry if the stack is empty.- Parameters:
valueIfEmpty-- Returns:
- int
-
push
public void push(int value)
Puts a value on the stack.- Parameters:
value-
-
-