scala.collection.mutable

class Queue

[source: scala/collection/mutable/Queue.scala]

@serializable

@cloneable

class Queue[A]
extends MutableList[A] with Cloneable[Queue[A]]
Queue objects implement data structures that allow to insert and retrieve elements in a first-in-first-out (FIFO) manner.
Author
Matthias Zenger
Martin Odersky
Version
2.8
Since
1
Direct Known Subclasses:
QueueProxy, SynchronizedQueue

Values and Variables inherited from MutableList
first0, last0, len
Method Summary
def dequeue : A
Returns the first element in the queue, and removes this element from the queue.
def dequeueAll (p : (A) => Boolean) : Seq[A]
Returns all elements in the queue which satisfy the given predicate, and removes those elements from the queue.
def dequeueFirst (p : (A) => Boolean) : Option[A]
Returns the first element in the queue which satisfies the given predicate, and removes this element from the queue.
def enqueue (elems : A*) : Unit
Adds all elements to the queue.
def extractFirst (start : LinkedList[A], p : (A) => Boolean) : Option[LinkedList[A]]
Return the proper suffix of this list which starts with the first element that satisfies `p`. That element is unlinked from the list. If no element satisfies `p`, return None.
def front : A
Returns the first element in the queue, or throws an error if there is no element contained in the queue.
Methods inherited from Cloneable
clone
Methods inherited from MutableList
newBuilder, isEmpty, head, tail, length, apply, update, get, prependElem, appendElem, reset, iterator, last, toList, +=, clear, result
Methods inherited from Builder
sizeHint, mapResult
Methods inherited from Growable
+=, ++=, ++=
Methods inherited from LinearSeq
companion
Methods inherited from LinearSeqLike
thisCollection, toCollection, foreach, forall, exists, count, find, foldLeft, foldRight, reduceLeft, reduceRight, take, drop, dropRight, slice, takeWhile, span, sameElements, lengthCompare, isDefinedAt, segmentLength, indexWhere, lastIndexWhere
Methods inherited from SeqLike
size, prefixLength, indexWhere, findIndexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, 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, hashCode, equals, toString, findLastIndexOf, equalsWith, containsSlice, projection
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from IterableLike
elements, toIterable, takeRight, copyToArray, zip, zipAll, zipWithIndex, toStream, canEqual, first, firstOption
Methods inherited from GenericTraversableTemplate
genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableLike
repr, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, /:, :\, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, lastOption, init, dropWhile, splitAt, copyToBuffer, copyToArray, toArray, toIndexedSeq, toSet, mkString, mkString, mkString, addString, addString, addString, stringPrefix, withFilter
Methods inherited from AnyRef
getClass, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
def enqueue(elems : A*) : Unit
Adds all elements to the queue.
Parameters
elems - the elements to add.

def dequeue : A
Returns the first element in the queue, and removes this element from the queue.
Throws
Predef.NoSuchElementException -
Returns
the first element of the queue.

def dequeueFirst(p : (A) => Boolean) : Option[A]
Returns the first element in the queue which satisfies the given predicate, and removes this element from the queue.
Parameters
p - the predicate used for choosing the first element
Returns
the first element of the queue for which p yields true

def dequeueAll(p : (A) => Boolean) : Seq[A]
Returns all elements in the queue which satisfy the given predicate, and removes those elements from the queue.
Parameters
p - the predicate used for choosing elements
Returns
a sequence of all elements in the queue for which p yields true.

def extractFirst(start : LinkedList[A], p : (A) => Boolean) : Option[LinkedList[A]]
Return the proper suffix of this list which starts with the first element that satisfies `p`. That element is unlinked from the list. If no element satisfies `p`, return None.

def front : A
Returns the first element in the queue, or throws an error if there is no element contained in the queue.
Returns
the first element.