public interface

IQueue

implements Iterable<T>
com.davidluoye.support.util.queue.IQueue<T>
Known Indirect Subclasses

Summary

Nested Classes
class IQueue.Itr<T>  
Public Methods
abstract boolean add(Collection<T> cc)
Inserts the specified elements into tail of this queue.
abstract boolean add(T t)
Inserts the specified element into tail of this queue.
abstract boolean add(T[] cc)
abstract boolean contains(Object o)
Returns true if this queue contains the specified element.
abstract int findEach(BiFunction<Integer, ? super T, Boolean> action)
abstract T findEach(Function<? super T, Boolean> action)
abstract void forEach(Consumer<? super T> action)
Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
abstract void forEach(BiConsumer<Integer, ? super T> action)
Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
abstract T get(int index)
Retrieves, but does not remove, the special index element of this queue.
abstract List<T> getQueue()
abstract 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.
abstract boolean isEmpty()
Returns true if this queue contains no elements.
abstract boolean isNotEmpty()
Returns true if this queue contains elements.
abstract Iterator<T> iterator()
abstract T peek()
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
abstract T poll()
Retrieves and removes the head of this queue, or returns null if this queue is empty.
abstract T pop()
Retrieves and removes the tail of this queue, or returns null if this queue is empty.
abstract T remove(int index)
Remove the special index element from this queue.
abstract void remove()
Remove all the elements from this queue.
abstract int size()
Returns the number of elements in this queue.
abstract 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.
abstract Stream<T> stream(int startInclusive, int endExclusive)
Returns a sequential Stream with the specified range of the specified array as its source.
abstract Stream<T> stream()
Returns a sequential Stream with this queue as its source.
abstract T tail()
Retrieves, but does not remove, the tail of this queue, or returns null if this queue is empty.
abstract Object[] toArray()
Returns an array containing all of the elements in this queue in proper sequence (from first to last element).
abstract <T> T[] toArray(T[] a)
Returns an array containing all of the elements in this queue in proper sequence (from first to last element).
abstract <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.
[Expand]
Inherited Methods
From interface java.lang.Iterable

Public Methods

public abstract 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 abstract 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 abstract boolean add (T[] cc)

public abstract boolean contains (Object o)

Returns true if this queue contains the specified element. More formally, returns true if and only if this queue contains at least one element e such that (o==null ? e==null : o.equals(e)).

Parameters
o element whose presence in this queue is to be tested
Returns
  • true if this queue contains the specified element
Throws
ClassCastException if the type of the specified element is incompatible with this queue (optional)

public abstract int findEach (BiFunction<Integer, ? super T, Boolean> action)

public abstract T findEach (Function<? super T, Boolean> action)

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

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of iteration (if an iteration order is specified). Exceptions thrown by the action are relayed to the caller.

The default implementation behaves as if:

for (T t : this)
         action.accept(t);
 

Parameters
action The action to be performed for each element
Throws
NullPointerException if the specified action is null

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

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of iteration (if an iteration order is specified). Exceptions thrown by the action are relayed to the caller.

Parameters
action The action to be performed for each element
Throws
NullPointerException if the specified action is null

public abstract 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 abstract List<T> getQueue ()

public abstract 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 abstract boolean isEmpty ()

Returns true if this queue contains no elements.

Returns
  • true if this queue contains no elements

public abstract boolean isNotEmpty ()

Returns true if this queue contains elements.

Returns
  • true if this queue contains elements

public abstract Iterator<T> iterator ()

public abstract 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 abstract 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 abstract 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 abstract 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 abstract void remove ()

Remove all the elements from this queue.

public abstract int size ()

Returns the number of elements in this queue.

Returns
  • the number of elements in this queue

public abstract 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
Throws
NullPointerException if the given array is null
ArrayIndexOutOfBoundsException if fromIndex is negative, toIndex is less than fromIndex, or toIndex is greater than the array size

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

Returns a sequential Stream with the specified range of the specified array as its source.

Parameters
startInclusive the first index to cover, inclusive
endExclusive index immediately past the last index to cover
Returns
  • a Stream for the array range
Throws
ArrayIndexOutOfBoundsException if startInclusive is negative, endExclusive is less than startInclusive, or endExclusive is greater than the array size

public abstract Stream<T> stream ()

Returns a sequential Stream with this queue as its source.

This method should be overridden when the spliterator() method cannot return a spliterator that is IMMUTABLE, CONCURRENT, or late-binding. (See spliterator() for details.) The default implementation creates a sequential Stream from the queue's Spliterator.

Returns
  • a sequential Stream over the elements in this collection

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