Class ArrayDeque<T>
java.lang.Object
org.javimmutable.collections.deque.ArrayDeque<T>
- All Implemented Interfaces:
Serializable,Iterable<T>,ICollection<T>,IDeque<T>,Indexed<T>,InvariantCheckable,IStreamable<T>,SplitableIterable<T>
IDeque implementation using 32-way trees. The underlying trees
only allow values to be inserted or deleted from the head or tail.
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionReplaces the value at the specified index (which must be within current bounds of the list) with the new value.static <T> ArrayDeque.Builder<T> builder()voidChecks invariants of implementing class.static <T> java.util.stream.Collector<T, ?, IDeque<T>> Removes the first value from the list and reduces size by 1.Removes the last value from the list and reduces size by 1.booleanfind(int index) Retrieves a Holder containing the (possibly null) value at the specified index if it exists.get(int index) Retrieves the value at the specified index (which must be within the bounds of the list).getList()Returns an unmodifiable List implementation backed by this list.intinthashCode()Adds a value to the end of the list.Adds the values to the end of the list in the same order they appear in the Iterable.Adds the values to the end of the list in the same order they appear in the Iterable.insertAllFirst(Iterable<? extends T> values) Adds the values to the beginning of the list in the same order they appear in the Iterable.insertAllFirst(Iterator<? extends T> values) Adds the values to the beginning of the list in the same order they appear in the Iterable.insertAllLast(Iterable<? extends T> values) Adds the values to the end of the list in the same order they appear in the Iterable.insertAllLast(Iterator<? extends T> values) Adds the values to the end of the list in the same order they appear in the Iterable.insertFirst(T value) Adds a value to the front of the list.insertLast(T value) Adds a value to the end of the list.booleanisEmpty()booleaniterator()Overridden here to require implementations to return a SplitableIterator rather than a basic Iterator.middle(int offset, int limit) Return the (possibly empty) list containing the values starting at offset (inclusive) and including all remaining items up to but excluding the value at index limit.static <T> ArrayDeque<T> of()static <T> IDeque<T> prefix(int limit) Return the (possibly empty) list containing the first limit values.Returns a list of the same type as this containing all those elements for which predicate returns false.reverse()Returns a list containing the same elements as this list but with their order reversed so that first in this list is last in returned list etc.Returns a list of the same type as this containing only those elements for which predicate returns true.intsize()Retrieve the number of values available in the container.suffix(int offset) Return the (possibly empty) list containing the values starting at offset (inclusive) and including all remaining items.toString()<A> ArrayDeque<A> Apply the transform function to all elements in iterator order and add each transformed value to a new collection of this type.<A> ArrayDeque<A> transformSome(Func1<T, Maybe<A>> transform) Apply the transform function to all elements in iterator order and add the contents of non-empty Holders to a new collection of this type.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.javimmutable.collections.IDeque
dequeCollector, singleMethods inherited from interface org.javimmutable.collections.Indexed
reversed, transformedMethods inherited from interface org.javimmutable.collections.IStreamable
parallelStream, spliterator, streamMethods inherited from interface org.javimmutable.collections.SplitableIterable
forEachThrows, indexedForEach, indexedForEachThrows, reduce, reduceThrows
-
Method Details
-
of
-
of
-
builder
-
collector
-
size
public int size()Description copied from interface:IndexedRetrieve the number of values available in the container. -
get
Description copied from interface:IDequeRetrieves the value at the specified index (which must be within the bounds of the list). -
find
Description copied from interface:IndexedRetrieves a Holder containing the (possibly null) value at the specified index if it exists. If no such value exists returns an empty Holder. -
assign
Description copied from interface:IDequeReplaces the value at the specified index (which must be within current bounds of the list) with the new value. -
insert
Description copied from interface:IDequeAdds a value to the end of the list. May be invoked on an empty list. -
select
Description copied from interface:IDequeReturns a list of the same type as this containing only those elements for which predicate returns true. Implementations are optimized assuming predicate will return false more often than true. -
reject
Description copied from interface:IDequeReturns a list of the same type as this containing all those elements for which predicate returns false. Implementations can be optimized assuming predicate will return false more often than true. -
insertFirst
Description copied from interface:IDequeAdds a value to the front of the list. May be invoked on an empty list. Synonym for insert()- Specified by:
insertFirstin interfaceIDeque<T>
-
insertLast
Description copied from interface:IDequeAdds a value to the end of the list. May be invoked on an empty list. Synonym for insert().- Specified by:
insertLastin interfaceIDeque<T>
-
insertAll
Description copied from interface:IDequeAdds the values to the end of the list in the same order they appear in the Iterable. May be invoked on an empty list. -
insertAll
Description copied from interface:IDequeAdds the values to the end of the list in the same order they appear in the Iterable. May be invoked on an empty list. -
insertAllFirst
Description copied from interface:IDequeAdds the values to the beginning of the list in the same order they appear in the Iterable. May be invoked on an empty list.- Specified by:
insertAllFirstin interfaceIDeque<T>- Returns:
- instance of list containing the collection
-
insertAllFirst
Description copied from interface:IDequeAdds the values to the beginning of the list in the same order they appear in the Iterable. May be invoked on an empty list.- Specified by:
insertAllFirstin interfaceIDeque<T>- Returns:
- instance of list containing the collection
-
insertAllLast
Description copied from interface:IDequeAdds the values to the end of the list in the same order they appear in the Iterable. May be invoked on an empty list. Synonym for insertAll()- Specified by:
insertAllLastin interfaceIDeque<T>- Returns:
- instance of list containing the collection
-
insertAllLast
Description copied from interface:IDequeAdds the values to the end of the list in the same order they appear in the Iterable. May be invoked on an empty list. Synonym for insertAll()- Specified by:
insertAllLastin interfaceIDeque<T>- Returns:
- instance of list containing the collection
-
deleteFirst
Description copied from interface:IDequeRemoves the first value from the list and reduces size by 1. size() must be greater than zero- Specified by:
deleteFirstin interfaceIDeque<T>- Returns:
- new
IListwithout last value
-
deleteLast
Description copied from interface:IDequeRemoves the last value from the list and reduces size by 1. size() must be greater than zero- Specified by:
deleteLastin interfaceIDeque<T>- Returns:
- new
IListwithout last value
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceICollection<T>- Returns:
- true only if collection contains no values
-
isNonEmpty
public boolean isNonEmpty()- Specified by:
isNonEmptyin interfaceICollection<T>- Returns:
- false only if collection contains no values
-
deleteAll
-
getList
Description copied from interface:IDequeReturns an unmodifiable List implementation backed by this list. -
reverse
Description copied from interface:IDequeReturns a list containing the same elements as this list but with their order reversed so that first in this list is last in returned list etc. -
iterator
Description copied from interface:IStreamableOverridden here to require implementations to return a SplitableIterator rather than a basic Iterator. This is necessary to allow composition of new objects from methods like keys() and values().- Specified by:
iteratorin interfaceIStreamable<T>- Specified by:
iteratorin interfaceIterable<T>- Specified by:
iteratorin interfaceSplitableIterable<T>
-
transform
Description copied from interface:IDequeApply the transform function to all elements in iterator order and add each transformed value to a new collection of this type. -
transformSome
Description copied from interface:IDequeApply the transform function to all elements in iterator order and add the contents of non-empty Holders to a new collection of this type.- Specified by:
transformSomein interfaceIDeque<T>- Parameters:
transform- transformation applied to each element- Returns:
- the collection after all elements have been processed
-
prefix
Description copied from interface:IDequeReturn the (possibly empty) list containing the first limit values. -
suffix
Description copied from interface:IDequeReturn the (possibly empty) list containing the values starting at offset (inclusive) and including all remaining items. -
middle
Description copied from interface:IDequeReturn the (possibly empty) list containing the values starting at offset (inclusive) and including all remaining items up to but excluding the value at index limit. -
getSpliteratorCharacteristics
public int getSpliteratorCharacteristics()- Specified by:
getSpliteratorCharacteristicsin interfaceIStreamable<T>- Returns:
- characteristics value used when creating Spliterators
-
checkInvariants
public void checkInvariants()Description copied from interface:InvariantCheckableChecks invariants of implementing class.- Specified by:
checkInvariantsin interfaceInvariantCheckable
-
equals
-
hashCode
public int hashCode() -
toString
-