Answered step by step
Verified Expert Solution
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 sizeReturns the number of items in this urgency queue.Specified by:size in interface QueueReturns:the number of items in this urgency queue.
enqueueboolean enqueueType itemInserts 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 QueueParameters:item the item to insertReturns:true if this urgency queue was modified as a result of this callThrows:NullPointerException if item is null
peekType peekRetrieves but does not remove, the most urgent item in this urgency queue.Specified by:peek in interface QueueReturns:the most urgent item in the queue.Throws:IllegalStateException if there are no items in the queue.
toStriSpecified by:toString in interface QueueOverrides:toString in class ObjectReturns:the string representation of this urgency queue
Type dequeueRetrieves and removes the most urgent item in this urgency queue.Specified by:dequeue in interface QueueReturns:the most urgent item in the queue.Throws:IllegalStateException if there are no items in the queue.
void dequeueConsumer actionRemoves the most urgent item in this urgency queue and performs the given action on the removed item.Specified by:dequeue in interface QueueParameters: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 userspecified behavior via one or more of its parameters. Users MUST ensure that the behavior that they specify is noninterfering.
UrgencyQueue dequeueManyint numBuilds and returns a new urgency queue that contains the most urgent num items dequeued from this UrgencyQueue.Specified by:dequeueMany in interface QueueParameters: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 IllegalStateException if num sizeImplementation Requirements:The new object MUST be the same type as the calling object
void dequeueManyint num, Consumer actionRemoves the most urgent nummany items in this urgency queue and performs the given action using action.accept on each item, in the Specified by:dequeueMany in interface QueueParameters: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 IllegalStateException if num sizeSee Also:Userspecified Behavior NoninterferenceAPI Notes:This method supports userspecified behavior via one or more of its parameters. Users MUST ensure that the behavior that they specify is noninterfering.
void clearRemoves all items from this urgency queue.Specified by:clear in interface Queue
UrgencyQueue filterPredicate condBuilds 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.teste returns true.Specified by:filter in interface QueueParameters:cond the predicate used to test items of this queue.
Throws:NullPointerException if the specified predicate is null.See Also:Userspecified Behavior NoninterferenceImplementation Requirements:The new object MUST be the same type as the calling object. This method MUST NOT modify the calling object.
boolean enqueueAllIterable itemsEnqueues 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 QueueType 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started