scala.collection.mutable
class Stack

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

@serializable
@cloneable
`` `class` Stack[A]
  `extends` MutableList[A]

  A stack implements a data structure which allows to store and retrieve objects in a last-in-first-out (LIFO) fashion.

Author
  Matthias Zenger
Version
  1.1, 03/05/2004

Direct Known Subclasses:
  StackProxy, SynchronizedStack

Values and Variables inherited from MutableList
first, last, len

Method Summary
`def` | ++= (iter : Iterable[A]) : Unit Pushes all elements provided by an `Iterable` object on top of the stack. The elements are pushed in the order they are given out by the iterator.
`def` | ++= (it : Iterator[A]) : Unit Pushes all elements provided by an iterator on top of the stack. The elements are pushed in the order they are given out by the iterator.
`def` | += (elem : A) : Unit Pushes a single element on top of the stack.
`def` | clear : Unit Removes all elements from the stack. After this operation completed, the stack will be empty.
`override def` | clone : Stack[A] This method clones the stack.
`override def` | elements : Iterator[A] Returns an iterator over all elements on the stack. This iterator is stable with respect to state changes in the stack object; i.e. such changes will not be reflected in the iterator. The iterator issues elements in the order they were inserted into the stack (FIFO order).
`override def` | equals (that : Any) : Boolean Checks if two stacks are structurally identical.
`override def` | hashCode : Int The hashCode method always yields an error, since it is not safe to use mutable stacks as keys in hash tables.
`override def` | isEmpty : Boolean Checks if the stack is empty.
`def` | pop : A Removes the top element from the stack.
`def` | push (elems : A*) : Unit Pushes a sequence of elements on top of the stack. The first element is pushed first, etc.
`protected override def` | stringPrefix : String Defines the prefix of this object's `toString` representation.
`override def` | toList : List[A] Creates a list of all stack elements in FIFO order.
`def` | top : A Returns the top element of the stack. This method will not remove the element from the stack. An error is signaled if there is no element on the stack.

Methods inherited from MutableList
length, apply, get, prependElem, appendElem, reset

Methods inherited from Seq
size, concat, ++, isDefinedAt, lastIndexOf, map, flatMap, filter, take, drop, takeWhile, dropWhile, reverse, contains, slice, subseq, toArray

Methods inherited from Collection
toString

Methods inherited from Iterable
foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, mkString, mkString, addString, addString, copyToArray, projection, hasDefiniteSize

Methods inherited from PartialFunction
orElse, andThen

Methods inherited from Function1
compose

Methods inherited from AnyRef
getClass, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized

Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf

Method Details

`override` `def` isEmpty : Boolean

  Checks if the stack is empty.

Returns
  true, iff there is no element on the stack

`` `def` +=(elem : A) : Unit

  Pushes a single element on top of the stack.

Parameters
  `elem -` the element to push onto the stack

`` `def` ++=(iter : Iterable[A]) : Unit

  Pushes all elements provided by an `Iterable` object on top of the stack. The elements are pushed in the order they are given out by the iterator.

Parameters
  `iter -` an iterable object

`` `def` ++=(it : Iterator[A]) : Unit

  Pushes all elements provided by an iterator on top of the stack. The elements are pushed in the order they are given out by the iterator.

Parameters
  `iter -` an iterator

`` `def` push(elems : A*) : Unit

  Pushes a sequence of elements on top of the stack. The first element is pushed first, etc.

Parameters
  `elems -` a sequence of elements

`` `def` top : A

  Returns the top element of the stack. This method will not remove the element from the stack. An error is signaled if there is no element on the stack.

Throws
  Predef.NoSuchElementException -
Returns
  the top element

`` `def` pop : A

  Removes the top element from the stack.

Throws
  Predef.NoSuchElementException -
Returns
  the top element

`` `def` clear : Unit

  Removes all elements from the stack. After this operation completed, the stack will be empty.

`override` `def` elements : Iterator[A]

  Returns an iterator over all elements on the stack. This iterator is stable with respect to state changes in the stack object; i.e. such changes will not be reflected in the iterator. The iterator issues elements in the order they were inserted into the stack (FIFO order).

Returns
  an iterator over all stack elements.

Overrides
  MutableList.elements

`override` `def` toList : List[A]

  Creates a list of all stack elements in FIFO order.

Returns
  the created list.

Overrides
  MutableList.toList

`override` `def` equals(that : Any) : Boolean

  Checks if two stacks are structurally identical.

Returns
  true, iff both stacks contain the same sequence of elements.

`override` `def` hashCode : Int

  The hashCode method always yields an error, since it is not safe to use mutable stacks as keys in hash tables.

Returns
  never.

`override` `def` clone : Stack[A]

  This method clones the stack.

Returns
  a stack with the same elements.

`protected override` `def` stringPrefix : String

  Defines the prefix of this object's `toString` representation.

Overrides
  MutableList.stringPrefix