Package components.stack
Class Stack3<T>
java.lang.Object
components.stack.StackSecondary<T>
components.stack.Stack3<T>
- Type Parameters:
T- type ofStackentries
- All Implemented Interfaces:
Stack<T>,StackKernel<T>,Standard<Stack<T>>,Iterable<T>
Stack represented as a Sequence of entries, with
implementations of primary methods.- Abstraction Relation (interpretation mapping between $this and this):
this = $this.entries
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclear()Resetsthisto an initial value.iterator()final intlength()Reports length ofthis.Returns a new object with the same dynamic type asthis, having an initial value.final Tpop()Removes and returns the entry at the top ofthis.final voidAddsxto the top ofthis.final TreplaceTop(T x) Replaces the top ofthiswithx, and returns the old top.final Ttop()Reports the top ofthis.final voidtransferFrom(Stack<T> source) Setsthisto the incoming value ofsource, and resetssourceto an initial value; the declaration notwithstanding, the dynamic type ofsourcemust be the same as the dynamic type ofthis.Methods inherited from class components.stack.StackSecondary
equals, flip, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Stack3
public Stack3()No-argument constructor.
-
-
Method Details
-
newInstance
Description copied from interface:StandardReturns a new object with the same dynamic type asthis, having an initial value. If the typeThas a no-argument constructor, then the value of the new returned object satisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, then the value of the new returned object satisfies the contract of the constructor call that was used to initializethis.- Returns:
- new object "like"
thiswith an initial value
-
clear
Description copied from interface:StandardResetsthisto an initial value. If the typeThas a no-argument constructor, thenthissatisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, thenthissatisfies the contract of the constructor call that was used to initialize#this. -
transferFrom
Description copied from interface:StandardSetsthisto the incoming value ofsource, and resetssourceto an initial value; the declaration notwithstanding, the dynamic type ofsourcemust be the same as the dynamic type ofthis. If the typeThas a no-argument constructor, thensourcesatisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, thensourcesatisfies the contract of the constructor call that was used to initialize#source.- Parameters:
source- object whose value is to be transferred
-
push
Description copied from interface:StackKernelAddsxto the top ofthis.- Parameters:
x- the entry to be added
-
pop
Description copied from interface:StackKernelRemoves and returns the entry at the top ofthis.- Returns:
- the entry removed
-
length
Description copied from interface:StackKernelReports length ofthis.- Returns:
- the length of
this
-
iterator
-
top
Description copied from interface:StackReports the top ofthis. -
replaceTop
Description copied from interface:StackReplaces the top ofthiswithx, and returns the old top.- Specified by:
replaceTopin interfaceStack<T>- Overrides:
replaceTopin classStackSecondary<T>- Parameters:
x- the new top entry- Returns:
- the old top entry
-