It from being added to the specified collection Queue, or some property of an element of this queue prevents Prevents it from being added to the specified collection NullPointerException - if the specified collection is null IllegalArgumentException - if the specified collection is this Is not supported by the specified collection ClassCastException - if the class of an element of this queue Specified by: drainTo in interface BlockingQueue Parameters: c - the collection to transfer elements into Returns: the number of elements transferred Throws: UnsupportedOperationException - if addition of elements Modified while the operation is in progress. This operation is undefined if the specified collection is Attempts to drain a queue to itself result in A failureĮncountered while attempting to add elements toĬollection c may result in elements being in neither,Įither or both collections when the associated exception is This operation may be moreĮfficient than repeatedly polling this queue. Removes all available elements from this queue and adds them This queue NullPointerException - if the specified array is null Is not a supertype of the runtime type of every element in Same runtime type is allocated for this purpose Returns: an array containing all of the elements in this queue Throws: ArrayStoreException - if the runtime type of the specified array Specified by: toArray in interface Collection Overrides: toArray in class AbstractCollection Type Parameters: T - the runtime type of the array to contain the collection Parameters: a - the array into which the elements of the queue are toīe stored, if it is big enough otherwise, a new array of the Note that toArray(new Object) is identical in function to The following code can be used to dump the queue into a newly Suppose x is a queue known to contain only strings. Under certain circumstances, be used to save allocation costs. Precise control over the runtime type of the output array, and may, Like the toArray() method, this method acts as bridge betweenĪrray-based and collection-based APIs. The array immediately following the end of the queue is set to (i.e., the array has more elements than this queue), the element in If this queue fits in the specified array with room to spare Runtime type of the specified array and the size of this queue. Otherwise, a new array is allocated with the If the queue fits in the specified array, it Proper sequence the runtime type of the returned array is that of Returns an array containing all of the elements in this queue, in Optional methods of the Collection and Iterator interfaces. This class and its iterator implement all of the Linked nodes areĭynamically created upon each insertion unless this would bring the Way to prevent excessive queue expansion. The optional capacity bound constructor argument serves as a Less predictable performance in most concurrent applications. Linked queues typically have higher throughput than array-based queues but Operations obtain elements at the head of the queue. The tail of the queue is that element that has been on theĪre inserted at the tail of the queue, and the queue retrieval The head of the queue is that element that has been on the This queue orders elements FIFO (first-in-first-out). The code below shows how to use the clear() method.An optionally-bounded blocking queue based on This method doesn’t take any parameters and does not return a value. After calling this method, the ConcurrentHashMap object becomes empty. The clear() method of the ConcurrentHashMap class removes all of the key-value mappings from a specified ConcurrentHashMap object.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |