Scala Library
|
|
scala/collection/immutable/Stack.scala
]
class
Stack[+A]
extends
Sequence[A]Stack
represent
empty stacks; they can be either created by calling the constructor
directly, or by applying the function Stack.Empty
.Method Summary | |
def
|
apply
(n : Int) : A
Returns the n-th element of this stack. The bottom element has index
0, elements above are indexed with increasing numbers.
|
override def
|
hashCode
: Int
Returns the hash code for this stack.
|
override def
|
isEmpty
: Boolean
Checks if this stack is empty.
|
override def
|
iterator
: Iterator[A]
Returns an iterator over all elements on the stack. The iterator
issues elements in the reversed order they were inserted into the
stack (LIFO order).
|
def
|
length
: Int
The number of elements in the stack
|
def
|
pop
: Stack[A]
Removes the top element from the stack.
|
def
|
push
[B >: A](elem1 : B, elem2 : B, elems : B*) : Stack[B]
Push a sequence of elements onto the stack. The last element
of the sequence will be on top of the new stack.
|
def
|
push
[B >: A](elem : B) : Stack[B]
Push an element on the stack.
|
def
|
pushAll
[B >: A](elems : Traversable[B]) : Stack[B]
Push all elements provided by the given traversable object onto
the stack. The last element returned by the iterable object
will be on top of the new stack.
|
def
|
pushAll
[B >: A](elems : Iterator[B]) : Stack[B]
Push all elements provided by the given iterator object onto
the stack. The last element returned by the iterable object
will be on top of the new stack.
|
override def
|
stringPrefix
: java.lang.String
Redefines the prefix of the string representation.
|
def
|
top
: A
Returns the top element of the stack. An error is signaled if
there is no element on the stack.
|
Methods inherited from Sequence | |
companion |
Methods inherited from SequenceTemplate | |
lengthCompare, size, isDefinedAt, zip, zipAll, zipWithIndex, segmentLength, prefixLength, indexWhere, indexWhere, findIndexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexWhere, lastIndexWhere, reverse, reverseIterator, reversedElements, startsWith, startsWith, endsWith, indexOfSeq, indexOfSeq, lastIndexOfSeq, lastIndexOfSeq, contains, union, diff, intersect, removeDuplicates, patch, padTo, toSequence, indices, view, view, equals, toString, sortWith, findLastIndexOf, slice, equalsWith, containsSlice, projection |
Methods inherited from PartialFunction | |
orElse, andThen |
Methods inherited from Function1 | |
compose |
Methods inherited from IterableTemplate | |
elements, foreach, foldRight, reduceRight, toIterable, head, takeRight, dropRight, sameElements, toStream, first, firstOption, toSeq |
Methods inherited from TraversableClass | |
newBuilder, genericBuilder, unzip, flatten, transpose |
Methods inherited from TraversableTemplate | |
thisCollection, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterMap, filterNot, remove, partition, groupBy, forall, exists, count, find, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, headOption, tail, last, lastOption, init, take, drop, slice, takeWhile, dropWhile, span, splitAt, copyToBuffer, copyToArray, copyToArray, toArray, toList, toSet, mkString, mkString, mkString, addString, addString, addString |
Methods inherited from AnyRef | |
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Class Summary | |
protected class
|
Node
[+B >: A](elem : B) extends Stack[B]
|
Method Details |
override
def
isEmpty : Boolean
def
length : Int
elem -
the element to push on the stack.elems -
the element sequence.elems -
the iterator object.
def
pushAll[B >: A](elems : Traversable[B]) : Stack[B]
elems -
the iterable object.
def
top : A
n -
the index number.override
def
hashCode : Int
override
def
stringPrefix : java.lang.String
Scala Library
|
|