Scala Library
|
|
scala/collection/immutable/Queue.scala
]
class
Queue[+A](elem : A*)
extends
Seq[A]Queue
objects implement data structures that allow to
insert and retrieve elements in a first-in-first-out (FIFO) manner.Value Summary | |
protected val
|
in : List[A] |
protected val
|
out : List[A] |
Method Summary | |
def
|
+
[B >: A](iter : Iterable[B]) : Queue[B]
Returns a new queue with all all elements provided by
an
Iterable object added at the end of
the queue.
The elements are prepended in the order they
are given out by the iterator. |
def
|
+
[B >: A](elem : B) : Queue[B]
Creates a new queue with element added at the end
of the old queue.
|
def
|
apply
(n : Int) : A
Returns the
n -th element of this queue.
The first element is at position 0. |
def
|
dequeue
: (A, Queue[A])
Returns a tuple with the first element in the queue,
and a new queue with this element removed.
|
override def
|
elements
: Iterator[A]
Returns the elements in the list as an iterator
|
def
|
enqueue
[B >: A](elem : B) : Queue[B]
Creates a new queue with element added at the end
of the old queue.
|
def
|
enqueue
[B >: A](iter : Iterable[B]) : Queue[B]
Returns a new queue with all all elements provided by
an
Iterable object added at the end of
the queue.
The elements are prepended in the order they
are given out by the iterator. |
override def
|
equals
(o : Any) : Boolean
Compares two queues for equality by comparing
each element in the queues.
|
def
|
front
: A
Returns the first element in the queue, or throws an error if there
is no element contained in the queue.
|
override def
|
hashCode
: Int
Returns a hash code value for the object.
|
override def
|
isEmpty
: Boolean
Checks if the queue is empty.
|
def
|
length
: Int
Returns the length of the queue.
|
protected def
|
mkQueue [A](i : List[A], o : List[A]) : Queue[A] |
override def
|
toString
: java.lang.String
Returns a string representation of this queue.
|
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, reverse, contains, subseq, toArray, toSeq, projection, equalsWith, startsWith, startsWith, endsWith, indexOf, containsSlice |
Methods inherited from Collection | |
stringPrefix |
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 |
Value Details |
Method Details |
n
-th element of this queue.
The first element is at position 0.n -
index of the element to returnn
in this queue.override
def
isEmpty : Boolean
def
length : Int
def
+[B >: A](elem : B) : Queue[B]
enqueue
from now on.elem -
the element to insertelem -
the element to insertIterable
object added at the end of
the queue.
The elements are prepended in the order they
are given out by the iterator.enqueue
from now on.iter -
an iterable objectIterable
object added at the end of
the queue.
The elements are prepended in the order they
are given out by the iterator.iter -
an iterable object
def
front : A
override
def
toString : java.lang.String
override
def
hashCode : Int
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash
codes (o1.hashCode.equals(o2.hashCode)
) yet not be
equal (o1.equals(o2)
returns false
). A
degenerate implementation could always return 0
.
However, it is required that if two objects are equal
(o1.equals(o2)
returns true
) that they
have identical hash codes
(o1.hashCode.equals(o2.hashCode)
). Therefore, when
overriding this method, be sure to verify that the behavior is
consistent with the equals
method.
Scala Library
|
|