Package com.zopim.android.sdk.util
Interface CircularQueue<E>
-
public interface CircularQueue<E>
Definition of interface queue that maintains the queue size by removing elements from the head of the queue if the capacity is violated. This queue orders elements FIFO (first-in-first-out).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description void
addAll(java.util.Collection<? extends E> collection)
Appends all of the elements in the specified collection to the end of this queue, in the order that they are returned by the specified collection's iterator.void
clear()
Removes all of the elements from this queue.boolean
contains(E element)
Returns true if this queue contains the specified element.boolean
isEmpty()
Returns true if this queue contains no elements.void
offer(E element)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.E
poll()
Retrieves and removes the head of this queue, or returns null if this queue is empty.int
size()
Returns the number of elements in this queue.E[]
toArray(E[] a)
Returns an array containing all of the elements in this queue, in proper sequence; the runtime type of the returned array is that of the specified array.
-
-
-
Method Detail
-
offer
void offer(E element)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.Violating capacity restrictions will result in a removal of an element at the head of the queue to accommodate space in the queue for a newly added element.
- Parameters:
element
- to add
-
poll
E poll()
Retrieves and removes the head of this queue, or returns null if this queue is empty.- Returns:
- the head of this queue, or null if this queue is empty
- See Also:
Queue.poll()
-
addAll
void addAll(java.util.Collection<? extends E> collection)
Appends all of the elements in the specified collection to the end of this queue, in the order that they are returned by the specified collection's iterator. Attempts to addAll of a queue to itself result in IllegalArgumentException.- Parameters:
collection
- the elements to be inserted into this queue- See Also:
Collection.addAll(Collection)
-
isEmpty
boolean isEmpty()
Returns true if this queue contains no elements.- Returns:
- true if this queue contains no elements
- See Also:
Collection.isEmpty()
-
size
int size()
Returns the number of elements in this queue.- Returns:
- the number of elements in this queue
- See Also:
Collection.size()
-
clear
void clear()
Removes all of the elements from this queue. The queue will be empty after this call returns.- See Also:
Collection.clear()
-
toArray
E[] toArray(E[] a)
Returns an array containing all of the elements in this queue, in proper sequence; the runtime type of the returned array is that of the specified array. If the queue fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this queue.- Parameters:
a
- The array into which the elements of the queue are to be stored.- Returns:
- an array of the elements
- See Also:
Collection.toArray(Object[])
-
contains
boolean contains(E element)
Returns true if this queue contains the specified element. More formally, returns true if and only if this queue contains at least one element e such that (o==null ? e==null : o.equals(e)).- Parameters:
element
- to look for in the queue- Returns:
- true if this queue contains the specified element
-
-