Class BlockingList<T>
java.lang.Object
com.sportradar.livedata.sdk.common.classes.BlockingList<T>
A list whose {code compareAndRemove} methods block until the specified item is removed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the passed instance to the list.voidcompareAndRemove(T item, long timeout) Blocks until the searched item is found and removed from the list.voidcompareAndRemove(T item, Comparator<T> comparator, long timeout) Blocks until the searched item is found and removed from the list.booleanisEmpty()Returns true if this list contains no elements.intsize()Returns the number of elements in this list.
-
Constructor Details
-
BlockingList
public BlockingList()
-
-
Method Details
-
size
public int size()Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.- Returns:
- the number of elements in this list.
-
isEmpty
public boolean isEmpty()Returns true if this list contains no elements.- Returns:
- true if this list contains no elements.
-
add
Adds the passed instance to the list.- Parameters:
item- the item to be added to the list.
-
compareAndRemove
Blocks until the searched item is found and removed from the list.- Parameters:
item- The item which is to be removed from the list or null to remove the first item.timeout- The time in milliseconds to wait for the item.- Throws:
InterruptedException- item was not found in the list in the time allowed time window.
-
compareAndRemove
public void compareAndRemove(T item, Comparator<T> comparator, long timeout) throws InterruptedException Blocks until the searched item is found and removed from the list.- Parameters:
item- The item which is to be removed from the list or null to remove the first item.comparator- theComparatorused to compare the stored items to the passed one.timeout- The time in milliseconds to wait for the item.- Throws:
InterruptedException- item was not found in the list in the time allowed time window.
-