|
Scala Library
|
|
scala/collection/immutable/Stack.scala]
class
Stack[+A](protected val elems : List[A])
extends Seq[A]Stack represent
empty stacks; they can be either created by calling the constructor
directly, or by applying the function Stack.Empty.| Additional Constructor Summary | |
def
|
this : Stack[A] |
| 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.
Note: should return
(A, Stack[A]) as for queues (mics) |
def
|
pop2 : (A, Stack[A]) |
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 : 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.
|
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.
|
override def
|
toString
: java.lang.String
Returns a string representation of this stack.
|
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 Seq | |
| companion |
| Methods inherited from SeqLike | |
| thisCollection, toCollection, lengthCompare, size, isDefinedAt, segmentLength, prefixLength, indexWhere, indexWhere, findIndexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexWhere, lastIndexWhere, reverse, reverseMap, reverseIterator, reversedElements, startsWith, startsWith, endsWith, indexOfSeq, indexOfSeq, lastIndexOfSeq, lastIndexOfSeq, contains, union, diff, intersect, removeDuplicates, patch, updated, +:, :+, padTo, sortWith, sortWith, sortBy, toSeq, indices, view, view, equals, findLastIndexOf, equalsWith, containsSlice, projection |
| Methods inherited from PartialFunction | |
| orElse, andThen |
| Methods inherited from Function1 | |
| compose |
| Methods inherited from IterableLike | |
| elements, foreach, forall, exists, find, foldRight, reduceRight, toIterable, head, take, slice, takeWhile, takeRight, dropRight, copyToArray, zip, zipAll, zipWithIndex, sameElements, toStream, canEqual, first, firstOption |
| Methods inherited from GenericTraversableTemplate | |
| newBuilder, genericBuilder, unzip, flatten, transpose |
| Methods inherited from TraversableLike | |
| repr, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, count, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, tail, last, lastOption, init, drop, dropWhile, span, splitAt, copyToBuffer, copyToArray, toArray, toList, toIndexedSeq, toSet, mkString, mkString, mkString, addString, addString, addString, stringPrefix, withFilter |
| Methods inherited from AnyRef | |
| getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
| Methods inherited from Any | |
| ==, !=, isInstanceOf, asInstanceOf |
| Additional Constructor Details |
| 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
(A, Stack[A]) as for queues (mics)n - the index number.override
def
hashCode : Int
override
def
toString : java.lang.String
|
Scala Library
|
|