Package org.kiwiproject.collect
Class KiwiEvictingQueues
java.lang.Object
org.kiwiproject.collect.KiwiEvictingQueues
Utility methods for working with Guava
EvictingQueue instances.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default maximum number ofEvictingQueueitems. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Queue<T>Create a new, synchronizedEvictingQueuethat can hold up toDEFAULT_MAX_RECENT_ITEMSitems.static <T> Queue<T>synchronizedEvictingQueue(int maxSize) Create a new, synchronizedEvictingQueuethat can hold up tomaxSizeitems.
-
Field Details
-
DEFAULT_MAX_RECENT_ITEMS
public static final int DEFAULT_MAX_RECENT_ITEMSThe default maximum number ofEvictingQueueitems.
-
-
Method Details
-
synchronizedEvictingQueue
Create a new, synchronizedEvictingQueuethat can hold up toDEFAULT_MAX_RECENT_ITEMSitems.- Type Parameters:
T- the type in the queue- Returns:
- a synchronized
EvictingQueue - See Also:
-
Queues.synchronizedQueue(Queue)
- API Note:
- returns a plain
Queuebecause Guava'sQueues.synchronizedQueue(Queue)returns aQueue. Any attempt to cast to anEvictingQueuewill result in aClassCastException. - Implementation Note:
- See synchronized notes regarding manual synchronization of the returned queue's
IteratorinQueues.synchronizedQueue(Queue)
-
synchronizedEvictingQueue
Create a new, synchronizedEvictingQueuethat can hold up tomaxSizeitems.- Type Parameters:
T- the type in the queue- Parameters:
maxSize- maximum size for the queue- Returns:
- a synchronized
EvictingQueue - See Also:
-
Queues.synchronizedQueue(Queue)
- API Note:
- returns a plain
Queuebecause Guava'sQueues.synchronizedQueue(Queue)returns aQueue. Any attempt to cast to anEvictingQueuewill result in aClassCastException. - Implementation Note:
- See synchronized notes regarding manual synchronization of the returned queue's
IteratorinQueues.synchronizedQueue(Queue)
-