Package components.queue
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 java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface components.queue.QueueKernel
dequeue, enqueue, lengthMethods inherited from interface components.standard.Standard
clear, newInstance, transferFrom
-
Method Details
-
front
Reports the front ofthis.- Returns:
- the front entry of
this - Aliases:
- reference returned by
front - Requires:
this /= <>- Ensures:
<front> is prefix of this
-
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
Concatenates ("appends")qto the end ofthis.- Parameters:
q- theQueueto be appended to the end ofthis- Updates:
this- Clears:
q- Ensures:
this = #this * #q
-
flip
void flip()Reverses ("flips")this.- Updates:
this- Ensures:
this = rev(#this)
-
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|)
-