E - the element type LinkedList does not provide
synchronization by default. And it behaves like fixed and not
fixed.
We can make it as fixed by providing the isFixed tag as true.
something as below.. FIFOQueue fifoQueue = new FIFOQueue(1000, true);
public class FIFOQueue<E> extends Object implements Collection<E>, List<E>, Serializable
LinkedList where all the
operations from/to this list are synchronized.LinkedList where as
LinkedList does not provide it by default.| Constructor and Description |
|---|
FIFOQueue()
Creates a list of small initial capacity.
|
FIFOQueue(Collection<? extends E> values)
Creates a list containing the specified values, in the order they are
returned by the collection's iterator.
|
FIFOQueue(int capacity,
boolean isFixed)
Creates a list of specified initial capacity if the
FIFOQueue is
not fixed, else it creates a Queue of the specified length; unless the
list size reaches the specified capacity, operations on this list will
not allocate memory (no lazy object creation). |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
void |
add(int index,
E element)
Adds the.
|
boolean |
addAll(Collection<? extends E> c)
Adds the all.
|
boolean |
addAll(int index,
Collection<? extends E> values)
Adds the all.
|
void |
addFIFOQueueItemRemovedListener(BufferOverflowListener<E> listener)
Adds the FIFOQueueItemRemovedListener to the list so that it can be
notified with an item that is to be removed.
|
void |
addFirst(E value)
Inserts the specified value at the beginning of this list.
|
boolean |
addLast(E value)
Appends the specified value to the end of this list (fast).
|
void |
await()
Causes the current thread to wait until it is signalled or.
|
void |
await(long time,
TimeUnit unit)
Causes the current thread to wait until it is signalled or specified time
is elapsed.
|
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
equals(Object obj) |
E |
get(int index) |
E |
getFirst()
Returns the first value of this list.
|
E |
getLast()
Returns the last value of this list.
|
int |
indexOf(Object value) |
boolean |
isEmpty() |
boolean |
isFixed()
Checks if is fixed.
|
Iterator<E> |
iterator() |
int |
lastIndexOf(Object value) |
ListIterator<E> |
listIterator() |
ListIterator<E> |
listIterator(int index) |
E |
pop()
Pops the element from the Queue.
|
void |
push(E value)
Pushes the specified value at the beginning of this Queue.
|
E |
remove(int index) |
boolean |
remove(Object value) |
boolean |
removeAll(Collection<?> c) |
void |
removeFIFOQueueItemRemovedListener(BufferOverflowListener<E> listener)
Removes the FIFOQueueItemRemovedListener from the list.
|
E |
removeFirst()
Removes and returns the first value of this list.
|
E |
removeLast()
Removes and returns the last value of this list (fast).
|
boolean |
retainAll(Collection<?> c) |
E |
set(int index,
E element)
Sets the.
|
void |
signal()
Wakes up one waiting thread.
|
void |
signalAll()
Wakes up all waiting threads.
|
int |
size() |
List<E> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] array) |
String |
toString() |
getClass, hashCode, notify, notifyAll, wait, wait, waithashCode, replaceAll, sort, spliteratorparallelStream, removeIf, streampublic FIFOQueue()
public FIFOQueue(int capacity,
boolean isFixed)
FIFOQueue is
not fixed, else it creates a Queue of the specified length; unless the
list size reaches the specified capacity, operations on this list will
not allocate memory (no lazy object creation).capacity - the initial capacity.isFixed - the flag to tell whether it is gonna be fixed or not.public FIFOQueue(Collection<? extends E> values)
values - the values to be placed into this list.public boolean remove(Object value)
public boolean addAll(Collection<? extends E> c)
public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>containsAll in interface List<E>public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public Object[] toArray()
public <T> T[] toArray(T[] array)
public boolean equals(Object obj)
public boolean addAll(int index,
Collection<? extends E> values)
public void add(int index,
E element)
public int lastIndexOf(Object value)
lastIndexOf in interface List<E>public ListIterator<E> listIterator(int index)
listIterator in interface List<E>public int size()
public boolean isEmpty()
public boolean contains(Object o)
public boolean add(E e)
public void clear()
public ListIterator<E> listIterator()
listIterator in interface List<E>public final E getFirst()
public final E getLast()
public final void addFirst(E value)
value - the value to be inserted.public boolean addLast(E value)
value - the value to be inserted.public final void push(E value)
addFirst(Object) , but kept for naming conventions.value - the value to be inserted.public E pop()
removeLast(),
but kept for naming conventions.public final E removeFirst()
public final E removeLast()
public boolean isFixed()
public void addFIFOQueueItemRemovedListener(BufferOverflowListener<E> listener)
listener - the listenerpublic void removeFIFOQueueItemRemovedListener(BufferOverflowListener<E> listener)
listener - the listenerpublic void await()
throws InterruptedException
InterruptedException - the interrupted exception interrupted.public void await(long time,
TimeUnit unit)
throws InterruptedException
time - the timeunit - the unitInterruptedException - the interrupted exception interrupted.public void signal()
If any threads are waiting on this condition then one is selected for
waking up. That thread must then re-acquire the lock before returning
from await.
public void signalAll()
If any threads are waiting on this condition then they are all woke up.
Each thread must re-acquire the lock before it can return from
await.
Copyright © 2016 utils4j. All Rights Reserved.