Class Stack<T>
java.lang.Object
weka.core.neighboursearch.covertrees.Stack<T>
- Type Parameters:
T
- The type of elements to be stored in the stack.
- All Implemented Interfaces:
Serializable
,RevisionHandler
Class implementing a stack.
- Version:
- $Revision: 10203 $
- Author:
- Alina Beygelzimer (original C++ code), Sham Kakade (original C++ code), John Langford (original C++ code), Ashraf M. Kibriya (amk14[at-the-rate]cs[dot]waikato[dot]ac[dot]nz) (Java port)
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAll
(Collection<? extends T> c) Adds all the given elements in the stack.void
clear()
Removes all the elements from the stack.element
(int i) Returns the ith element in the stack.Returns the revision string.last()
Returns the last element in the stack.pop()
Pops (removes) the first (last added) element in the stack.void
Pushes the given element to the stack.void
Pushes the given element onto the given stack.void
replaceAllBy
(Stack<T> s) Replace all elements in the stack with the elements of another given stack.void
Sets the ith element in the stack.subList
(int beginIdx, int uptoLength) Returns a sublist of the elements in the stack.
-
Field Details
-
length
public int lengthThe number of elements in the stack. -
elements
The elements inside the stack.
-
-
Constructor Details
-
Stack
public Stack()Constructor. -
Stack
public Stack(int capacity) Constructor.- Parameters:
capacity
- The initial capacity of the stack.
-
-
Method Details
-
last
Returns the last element in the stack.- Returns:
- The last element.
-
element
Returns the ith element in the stack.- Parameters:
i
- The index of the element to return.- Returns:
- The ith element.
-
set
Sets the ith element in the stack.- Parameters:
i
- The index at which the element is to be inserted.e
- The element to insert.
-
subList
Returns a sublist of the elements in the stack.- Parameters:
beginIdx
- The start index of the sublist.uptoLength
- The length of the sublist.- Returns:
- The sublist starting from beginIdx and of length uptoLength.
-
clear
public void clear()Removes all the elements from the stack. -
addAll
Adds all the given elements in the stack.- Parameters:
c
- The collection of elements to add in the stack.
-
replaceAllBy
Replace all elements in the stack with the elements of another given stack. It first removes all the elements currently in the stack, and then adds all the elements of the provided stack.- Parameters:
s
- The stack whose elements should be put in this stack.
-
pop
Pops (removes) the first (last added) element in the stack.- Returns:
- The poped element.
-
push
Pushes the given element to the stack.- Parameters:
new_ele
- The element to be pushed to the stack.
-
push
Pushes the given element onto the given stack.- Parameters:
v
- The stack onto push the element.new_ele
- The element to push.
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-