Scala Library
|
|
scala/collection/immutable/Stack.scala
]
class
Stack[+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
.Method Summary | |
def
|
+
[B >: A](elems : Iterable[B]) : Stack[B]
Push all elements provided by the given iterable object onto
the stack. The last element returned by the iterable object
will be on top of the new stack.
|
def
|
+
[B >: A](elem : B) : Stack[B]
Push an element on the stack.
|
override def
|
++
[B >: A](elems : Iterable[B]) : Stack[B]
Push all elements provided by the given iterable object onto
the stack. The last element returned by the iterable object
will be on top of the new stack.
|
def
|
++
[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
|
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
|
elements
: 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).
|
override def
|
equals
(obj : Any) : Boolean
Compares this stack with the given object.
|
override def
|
hashCode
: Int
Returns the hash code for this stack.
|
override def
|
isEmpty
: Boolean
Checks if this stack is empty.
|
def
|
length
: Int
Returns the size of this stack.
|
def
|
pop
: Stack[A]
Removes the top element from the stack.
|
def
|
push
[B >: A](elem : B) : Stack[B]
Push an element on the stack.
|
def
|
push
[B >: A](elems : Iterable[B]) : Stack[B]
Push all elements provided by the given iterable object onto
the stack. The last element returned by the iterable object
will be on top of the new stack.
|
def
|
push
[B >: A](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.
|
override def
|
reverse
: Stack[A]
A stack consisting of all elements of this stack in reverse order.
|
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 Seq | |
lengthCompare, size, concat, last, lastOption, first, firstOption, headOption, isDefinedAt, lastIndexOf, findIndexOf, indexOf, map, flatMap, filter, take, drop, slice, slice, takeWhile, dropWhile, contains, subseq, toArray, toSeq, projection, equalsWith, startsWith, startsWith, endsWith, indexOf, containsSlice |
Methods inherited from Collection | |
toString |
Methods inherited from Iterable | |
partition, foreach, forall, exists, find, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, toStream, mkString, mkString, mkString, addString, addString, addString, copyToArray, hasDefiniteSize |
Methods inherited from PartialFunction | |
orElse, andThen |
Methods inherited from Function1 | |
compose |
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
def
+[B >: A](elem : B) : Stack[B]
push
from now on.elem -
the element to push on the stack.elem -
the element to push on the stack.elems -
the element sequence.push
from now on.elems -
the iterable object.elems -
the iterable object.elems -
the iterator object.elems -
the iterable object.
def
top : A
n -
the index number.override
def
hashCode : Int
override
def
stringPrefix : java.lang.String
Scala Library
|
|