public class

SynchronizedFixQueue

extends FixQueue<T>
java.lang.Object
   ↳ com.davidluoye.support.util.queue.FixQueue<T>
     ↳ com.davidluoye.support.util.queue.SynchronizedFixQueue<T>

Summary

Public Constructors
SynchronizedFixQueue()
SynchronizedFixQueue(int maxCapacity)
SynchronizedFixQueue(T[] array)
SynchronizedFixQueue(T[] array, int maxCapacity)
SynchronizedFixQueue(int initCapacity, int maxCapacity)
Public Methods
boolean add(Collection<T> cc)
Inserts the specified elements into tail of this queue.
boolean add(T t)
Inserts the specified element into tail of this queue.
boolean add(T[] cc)
void forEach(Consumer<? super T> action)
void forEach(BiConsumer<Integer, ? super T> action)
T get(int index)
Retrieves, but does not remove, the special index element of this queue.
List<T> getQueue()
int indexOf(T t)
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
boolean isEmpty()
boolean isNotEmpty()
static <T> SynchronizedFixQueue<T> of(T... ts)
static <T> SynchronizedFixQueue<T> of(int maxCapacity, T... ts)
T peek()
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
T poll()
Retrieves and removes the head of this queue, or returns null if this queue is empty.
T pop()
Retrieves and removes the tail of this queue, or returns null if this queue is empty.
T remove(int index)
Remove the special index element from this queue.
void remove()
Remove all the elements from this queue.
int size()
Returns the number of elements in this queue.
Stream<T> stream(int startInclusive, int endExclusive)
Stream<T> stream()
T tail()
Retrieves, but does not remove, the tail of this queue, or returns null if this queue is empty.
<T1> T1[] toArray(T1[] a)
Returns an array containing all of the elements in this queue in proper sequence (from first to last element).
Object[] toArray()
Returns an array containing all of the elements in this queue in proper sequence (from first to last element).
<A> A[] toArray(IntFunction<A[]> generator)
Returns an array containing the elements of this stream, using the provided generator function to allocate the returned array, as well as any additional arrays that might be required for a partitioned execution or for resizing.
Protected Methods
FixQueue<T> onCloneNewQueue(int maxCapacity)
[Expand]
Inherited Methods
From class com.davidluoye.support.util.queue.FixQueue
From class java.lang.Object
From interface com.davidluoye.support.util.queue.IQueue
From interface java.lang.Iterable

Public Constructors

public SynchronizedFixQueue ()

public SynchronizedFixQueue (int maxCapacity)

public SynchronizedFixQueue (T[] array)

public SynchronizedFixQueue (T[] array, int maxCapacity)

public SynchronizedFixQueue (int initCapacity, int maxCapacity)

Public Methods

public boolean add (Collection<T> cc)

Inserts the specified elements into tail of this queue. If the element in this queue has reached max count, then remove the head firstly and insert the new one into tail.

Parameters
cc the element to add
Returns
  • true (as specified by add(E))

public boolean add (T t)

Inserts the specified element into tail of this queue. If the element in this queue has reached max count, then remove the head firstly and insert the new one into tail.

Parameters
t the element to add
Returns
  • true (as specified by add(E))

public boolean add (T[] cc)

public void forEach (Consumer<? super T> action)

public void forEach (BiConsumer<Integer, ? super T> action)

public T get (int index)

Retrieves, but does not remove, the special index element of this queue.

Returns
  • the special index element

public List<T> getQueue ()

public int indexOf (T t)

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

public boolean isEmpty ()

public boolean isNotEmpty ()

public static SynchronizedFixQueue<T> of (T... ts)

public static SynchronizedFixQueue<T> of (int maxCapacity, T... ts)

public T peek ()

Retrieves, but does not remove, 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

public T 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

public T pop ()

Retrieves and removes the tail of this queue, or returns null if this queue is empty.

Returns
  • the tail of this queue, or null if this queue is empty

public T remove (int index)

Remove the special index element from this queue.

Returns
  • the special index element

public void remove ()

Remove all the elements from this queue.

public int size ()

Returns the number of elements in this queue.

Returns
  • the number of elements in this queue

public Stream<T> stream (int startInclusive, int endExclusive)

public Stream<T> stream ()

public T tail ()

Retrieves, but does not remove, the tail of this queue, or returns null if this queue is empty.

Returns
  • the tail of this queue, or null if this queue is empty

public T1[] toArray (T1[] a)

Returns an array containing all of the elements in this queue in proper sequence (from first to last element).

The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

Returns
  • an array containing all of the elements in this queue in proper sequence

public Object[] toArray ()

Returns an array containing all of the elements in this queue in proper sequence (from first to last element).

The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

Returns
  • an array containing all of the elements in this queue in proper sequence

public A[] toArray (IntFunction<A[]> generator)

Returns an array containing the elements of this stream, using the provided generator function to allocate the returned array, as well as any additional arrays that might be required for a partitioned execution or for resizing.

This is a terminal operation. The generator function takes an integer, which is the size of the desired array, and produces an array of the desired size. This can be concisely expressed with an array constructor reference:

Person[] men = people.stream()
                          .filter(p -> p.getGender() == MALE)
                          .toArray(Person[]::new);
 

Parameters
generator a function which produces a new array of the desired type and the provided length
Returns
  • an array containing the elements in this stream

Protected Methods

protected FixQueue<T> onCloneNewQueue (int maxCapacity)