public class

FixQueue

extends Object
implements IQueue<T>
java.lang.Object
   ↳ com.davidluoye.support.util.queue.FixQueue<T>
Known Direct Subclasses

Summary

Public Constructors
FixQueue()
FixQueue(int maxCapacity)
FixQueue(T[] array)
FixQueue(T[] array, int maxCapacity)
FixQueue(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.
final FixQueue<T> clone(boolean immutable)
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.
static <T> FixQueue<T> of(T... ts)
static <T> FixQueue<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.
Spliterator<T> spliterator(int startInclusive, int endExclusive)
Creates a Spliterator covering a range of elements of a given array, using a customized set of spliterator characteristics.
T tail()
Retrieves, but does not remove, the tail of this queue, or returns null if this queue is empty.
<T> T[] toArray(T[] 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.
String toString()
Protected Methods
FixQueue<T> onCloneNewQueue(int maxCapacity)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.davidluoye.support.util.queue.IQueue
From interface java.lang.Iterable

Public Constructors

public FixQueue ()

public FixQueue (int maxCapacity)

public FixQueue (T[] array)

public FixQueue (T[] array, int maxCapacity)

public FixQueue (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 final FixQueue<T> clone (boolean immutable)

public T get (int index)

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

Returns
  • the special index element
Throws
IndexOutOfBoundsException if index is not valid

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 static FixQueue<T> of (T... ts)

public static FixQueue<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
Throws
IndexOutOfBoundsException if index is not valid

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 Spliterator<T> spliterator (int startInclusive, int endExclusive)

Creates a Spliterator covering a range of elements of a given array, using a customized set of spliterator characteristics.

This method is provided as an implementation convenience for Spliterators which store portions of their elements in arrays, and need fine control over Spliterator characteristics. Most other situations in which a Spliterator for an array is needed should use spliterator(Object[]).

The returned spliterator always reports the characteristics SIZED and SUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specify IMMUTABLE and ORDERED.

Parameters
startInclusive The least index (inclusive) to cover
endExclusive One past the greatest index to cover
Returns
  • A spliterator for an array

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 T[] toArray (T[] 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
Throws
ArrayStoreException if the runtime type of the array returned from the array generator is not a supertype of the runtime type of every element in this stream

public String toString ()

Protected Methods

protected FixQueue<T> onCloneNewQueue (int maxCapacity)