scala.collection.immutable
class Stack

[source: `scala/collection/immutable/Stack.scala`]

@serializable
`` `class` Stack[+A]
  `extends` Seq[A]

  This class implements immutable stacks using a list-based data structure. Instances of `Stack` represent empty stacks; they can be either created by calling the constructor directly, or by applying the function `Stack.Empty`.

Author
  Matthias Zenger
Version
  1.0, 10/07/2003

Direct Known Subclasses:
  Stack.Node

Method Summary
`def` | + [B >: A](elem : B) : Stack[B] Push an element on the stack.
`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` | apply (n : Int) : A Returns the n-th element of this stack. The top element has index 0, elements below 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](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` | stringPrefix : 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
size, concat, last, lastOption, headOption, ++, isDefinedAt, lastIndexOf, map, flatMap, filter, take, drop, slice, takeWhile, dropWhile, reverse, contains, subseq, toArray, projection, equalsWith, startsWith, endsWith, indexOf, containsSlice

Methods inherited from Collection
toString

Methods inherited from Iterable
foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, toStream, mkString, mkString, mkString, 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]