Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Method Detailssizeint size ( ) Returns the number of items in this urgency queue.Specified by:size in interface Queue > Returns:the number of items in this

Method Detailssizeint size()Returns the number of items in this urgency queue.Specified by:size in interface Queue>Returns:the number of items in this urgency queue.
enqueueboolean enqueue(Type item)Inserts the specified item into this urgency queue. The inserted item is placed such that it appears after any existing items with the same or greater level of urgency and before any existing items with a lesser level of urgency.Specified by:enqueue in interface Queue>Parameters:item - the item to insertReturns:true if this urgency queue was modified as a result of this callThrows:NullPointerException - if item is null
peekType peek()Retrieves, but does not remove, the most urgent item in this urgency queue.Specified by:peek in interface Queue>Returns:the most urgent item in the queue.Throws:IllegalStateException - if there are no items in the queue.
toStriSpecified by:toString in interface Queue>Overrides:toString in class ObjectReturns:the string representation of this urgency queue
Type dequeue()Retrieves and removes the most urgent item in this urgency queue.Specified by:dequeue in interface Queue>Returns:the most urgent item in the queue.Throws:IllegalStateException - if there are no items in the queue.
void dequeue(Consumer action)Removes the most urgent item in this urgency queue and performs the given action on the removed item.Specified by:dequeue in interface Queue>Parameters:action - the action to be performed on the removed item.Throws:NullPointerException - if the specified action is null.IllegalStateException - if there are no items in the queue.
API Notes:This method supports user-specified behavior via one or more of its parameters. Users MUST ensure that the behavior that they specify is non-interfering.
UrgencyQueue dequeueMany(int num)Builds and returns a new urgency queue that contains the most urgent num items dequeued from this UrgencyQueue.Specified by:dequeueMany in interface Queue>Parameters:num - the number of items to remove and return.Returns:a new urgency queue object containing the most urgent num items dequeued from this queue
Throws:IllegalArgumentException - if num 0.IllegalStateException - if num > size().Implementation Requirements:The new object MUST be the same type as the calling object
void dequeueMany(int num, Consumer action)Removes the most urgent num-many items in this urgency queue and performs the given action (using action.accept) on each item, in the .Specified by:dequeueMany in interface Queue>Parameters:num - the number of items to remove.action - the action to be performed on the removed items.Throws:NullPointerException - if the specified action is null.
IllegalArgumentException - if num 0.IllegalStateException - if num > size().See Also:User-specified Behavior Non-interferenceAPI Notes:This method supports user-specified behavior via one or more of its parameters. Users MUST ensure that the behavior that they specify is non-interfering.
void clear()Removes all items from this urgency queue.Specified by:clear in interface Queue>
UrgencyQueue filter(Predicate cond)Builds and returns a new urgency queue consisting of the items of this urgency queue that pass the test specified by the given predicate. The term predicate usually refers to some function that returns either true or false. Here, it refers to the parameter cond, which should refer to an object of a class that implements the Predicate interface. More formally, this method returns a new urgency queue containing all items e in this queue such that cond.test(e) returns true.Specified by:filter in interface Queue>Parameters:cond - the predicate used to test items of this queue.
Throws:NullPointerException - if the specified predicate is null.See Also:User-specified Behavior Non-interferenceImplementation Requirements:The new object MUST be the same type as the calling object. This method MUST NOT modify the calling object.
boolean enqueueAll(Iterable items)Enqueues the items contained in the specified Iterable into this urgency queue. This method should return false if the specified Iterable is empty. Otherwise, this method either returns true or throws an exception upon failure.Specified by:enqueueAll in interface Queue>Type Parameters:SubType - the type of the items to be added.Parameters:items - the items to add to this queue.
Returns:true if this queue is changed as a result of the call; false otherwise.Throws:NullPointerException - if items is null.IllegalArgumentException - if any of the items in the specified Iterable are null.Implementation Requirements:The calling object MUST NOT be modified if any item in items is null.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Why is it important to think about feedback loops?

Answered: 1 week ago

Question

Create a Matlab variable with the value ' Z ' z is a character

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago