Interface Queue<T>
- Type Parameters:
T- type ofQueueentries
- All Superinterfaces:
Iterable<T>, QueueKernel<T>, Standard<Queue<T>>
- All Known Implementing Classes:
Queue1L, Queue2, Queue3, QueueSecondary
QueueKernel enhanced with secondary methods.- Mathematical Definitions:
IS_TOTAL_PREORDER ( r: binary relation on T ) : boolean is for all x, y, z: T ((r(x, y) or r(y, x)) and (if (r(x, y) and r(y, z)) then r(x, z))) IS_SORTED ( s: string of T, r: binary relation on T ) : boolean is for all x, y: T where (<x, y> is substring of s) (r(x, y))
-
Method Summary
Modifier and TypeMethodDescriptionvoidConcatenates ("appends")qto the end ofthis.voidflip()Reverses ("flips")this.front()Reports the front ofthis.replaceFront(T x) Replaces the front ofthiswithx, and returns the old front.voidrotate(int distance) Rotatesthis.voidsort(Comparator<T> order) Sortsthisaccording to the ordering provided by thecomparemethod fromorder.Methods inherited from interface Iterable
forEach, iterator, spliteratorMethods inherited from interface QueueKernel
dequeue, enqueue, lengthMethods inherited from interface Standard
clear, newInstance, transferFrom
-
Method Details
-
front
-
replaceFront
Replaces the front ofthiswithx, and returns the old front.- Parameters:
x- the new front entry- Returns:
- the old front entry
- Aliases:
- reference
x - Updates:
this- Requires:
this /= <>- Ensures:
<replaceFront> is prefix of #this and this = <x> * #this[1, |#this|)
-
append
-
flip
-
sort
Sortsthisaccording to the ordering provided by thecomparemethod fromorder.- Parameters:
order- ordering by which to sort- Updates:
this- Requires:
IS_TOTAL_PREORDER([relation computed by order.compare method])- Ensures:
perms(this, #this) and IS_SORTED(this, [relation computed by order.compare method])
-
rotate
Rotatesthis.- Parameters:
distance- distance by which to rotate- Updates:
this- Ensures:
if #this = <> then this = #this else this = #this[distance mod |#this|, |#this|) * #this[0, distance mod |#this|)
-