Class ShortArrayList
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractShortIterable
org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList
- All Implemented Interfaces:
Externalizable
,Serializable
,MutableShortCollection
,MutableShortList
,ShortList
,OrderedShortIterable
,ReversibleShortIterable
,PrimitiveIterable
,ShortIterable
public class ShortArrayList extends AbstractShortIterable implements MutableShortList, Externalizable
ShortArrayList is similar to
FastList
, and is memory-optimized for short primitives.
This file was automatically generated from template file primitiveArrayList.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description ShortArrayList()
ShortArrayList(int initialCapacity)
ShortArrayList(short... array)
-
Method Summary
Modifier and Type Method Description boolean
add(short newItem)
boolean
addAll(short... source)
boolean
addAll(ShortIterable source)
boolean
addAllAtIndex(int index, short... source)
boolean
addAllAtIndex(int index, ShortIterable source)
void
addAtIndex(int index, short element)
boolean
allSatisfy(ShortPredicate predicate)
Returns true if all of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(ShortPredicate predicate)
Returns true if any of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.void
appendString(Appendable appendable, String start, String separator, String end)
Prints a string representation of this collection onto the givenAppendable
.LazyShortIterable
asReversed()
MutableShortList
asSynchronized()
MutableShortList
asUnmodifiable()
int
binarySearch(short value)
RichIterable<ShortIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<V> MutableList<V>
collect(ShortToObjectFunction<? extends V> function)
Returns a new collection with the results of applying the specified function on each element of the source collection.<V, R extends Collection<V>>
Rcollect(ShortToObjectFunction<? extends V> function, R target)
Same asShortIterable.collect(ShortToObjectFunction)
, only the results are added to the target Collection.boolean
contains(short value)
Returns true if the value is contained in the ShortIterable, and false if it is not.int
count(ShortPredicate predicate)
Returns a count of the number of elements in the ShortIterable that return true for the specified predicate.short
detectIfNone(ShortPredicate predicate, short ifNone)
MutableShortList
distinct()
long
dotProduct(ShortList list)
void
each(ShortProcedure procedure)
A synonym for forEach.void
ensureCapacity(int minCapacity)
boolean
equals(Object otherList)
Follows the same general contract asList.equals(Object)
.void
forEach(ShortProcedure procedure)
Applies the ShortProcedure to each element in the ShortIterable.void
forEachWithIndex(ShortIntProcedure procedure)
short
get(int index)
short
getFirst()
short
getLast()
int
hashCode()
Follows the same general contract asList.hashCode()
.int
indexOf(short value)
<T> T
injectInto(T injectedValue, ObjectShortToObjectFunction<? super T,? extends T> function)
<T> T
injectIntoWithIndex(T injectedValue, ObjectShortIntToObjectFunction<? super T,? extends T> function)
int
lastIndexOf(short value)
short
max()
short
min()
ShortArrayList
newEmpty()
Creates a new empty ShortArrayList.static ShortArrayList
newList(ShortIterable source)
static ShortArrayList
newListWith(short... elements)
Creates a new list using the passedelements
argument as the backing store.static ShortArrayList
newWithNValues(int size, short value)
boolean
noneSatisfy(ShortPredicate predicate)
Returns true if none of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.void
readExternal(ObjectInput in)
ShortArrayList
reject(ShortPredicate predicate)
Returns a new ShortIterable with all of the elements in the ShortIterable that return false for the specified predicate.<R extends MutableShortCollection>
Rreject(ShortPredicate predicate, R target)
Same asShortIterable.reject(ShortPredicate)
, only the results are added to the target MutableShortCollection.boolean
remove(short value)
boolean
removeAll(short... source)
boolean
removeAll(ShortIterable source)
short
removeAtIndex(int index)
boolean
removeIf(ShortPredicate predicate)
boolean
retainAll(short... source)
boolean
retainAll(ShortIterable source)
ShortArrayList
reverseThis()
ShortArrayList
select(ShortPredicate predicate)
Returns a new ShortIterable with all of the elements in the ShortIterable that return true for the specified predicate.<R extends MutableShortCollection>
Rselect(ShortPredicate predicate, R target)
Same asShortIterable.select(ShortPredicate)
, only the results are added to the target MutableShortCollection.short
set(int index, short element)
MutableShortIterator
shortIterator()
Returns a primitive iterator that can be used to iterate over the ShortIterable in an imperative style.int
size()
Returns the number of items in this iterable.ShortArrayList
sortThis()
Sorts this list mutating its contents and returns the same mutable list (this).ShortArrayList
sortThis(ShortComparator comparator)
Sorts the internal data structure of this list and returns the list itself as a convenience.MutableShortList
subList(int fromIndex, int toIndex)
long
sum()
void
swap(int index1, int index2)
short[]
toArray()
Converts the ShortIterable to a primitive short array.short[]
toArray(short[] target)
Converts the ShortIterable to a primitive short array.ImmutableShortList
toImmutable()
Returns an immutable copy of this list.ShortArrayList
toReversed()
void
trimToSize()
ShortArrayList
with(short element)
ShortArrayList
with(short element1, short element2)
ShortArrayList
with(short element1, short element2, short element3)
ShortArrayList
with(short element1, short element2, short element3, short... elements)
ShortArrayList
withAll(ShortIterable elements)
ShortArrayList
without(short element)
ShortArrayList
withoutAll(ShortIterable elements)
static ShortArrayList
wrapCopy(short... array)
Creates a new list by first copying the array passed in.void
writeExternal(ObjectOutput out)
<T> MutableList<ShortObjectPair<T>>
zip(Iterable<T> iterable)
Returns aMutableList
formed from thisMutableShortList
and aListIterable
by combining corresponding elements in pairs.MutableList<ShortShortPair>
zipShort(ShortIterable iterable)
Returns aMutableList
formed from thisMutableShortList
and anotherShortList
by combining corresponding elements in pairs.Methods inherited from class org.eclipse.collections.impl.primitive.AbstractShortIterable
asLazy, average, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
Methods inherited from interface org.eclipse.collections.api.list.primitive.MutableShortList
collectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tap
Methods inherited from interface org.eclipse.collections.api.ordered.primitive.OrderedShortIterable
collectWithIndex
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
Methods inherited from interface org.eclipse.collections.api.ShortIterable
asLazy, average, averageIfEmpty, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAll, containsAll, flatCollect, maxIfEmpty, median, medianIfEmpty, minIfEmpty, reduce, reduceIfEmpty, summaryStatistics, toBag, toList, toSet, toSortedArray, toSortedList
-
Constructor Details
-
ShortArrayList
public ShortArrayList() -
ShortArrayList
public ShortArrayList(int initialCapacity) -
ShortArrayList
public ShortArrayList(short... array)
-
-
Method Details
-
newListWith
Creates a new list using the passedelements
argument as the backing store.!!! WARNING: This method uses the passed in array, so can be very unsafe if the original array is held onto anywhere else. !!!
-
newList
-
newWithNValues
-
wrapCopy
Creates a new list by first copying the array passed in. -
size
public int size()Description copied from interface:PrimitiveIterable
Returns the number of items in this iterable.- Specified by:
size
in interfacePrimitiveIterable
-
clear
public void clear()- Specified by:
clear
in interfaceMutableShortCollection
-
contains
public boolean contains(short value)Description copied from interface:ShortIterable
Returns true if the value is contained in the ShortIterable, and false if it is not.- Specified by:
contains
in interfaceShortIterable
-
get
public short get(int index) -
getFirst
public short getFirst()- Specified by:
getFirst
in interfaceOrderedShortIterable
-
getLast
public short getLast()- Specified by:
getLast
in interfaceReversibleShortIterable
-
indexOf
public int indexOf(short value)- Specified by:
indexOf
in interfaceOrderedShortIterable
-
lastIndexOf
public int lastIndexOf(short value)- Specified by:
lastIndexOf
in interfaceShortList
-
trimToSize
public void trimToSize() -
ensureCapacity
public void ensureCapacity(int minCapacity) -
add
public boolean add(short newItem)- Specified by:
add
in interfaceMutableShortCollection
-
addAll
public boolean addAll(short... source)- Specified by:
addAll
in interfaceMutableShortCollection
-
addAll
- Specified by:
addAll
in interfaceMutableShortCollection
-
addAtIndex
public void addAtIndex(int index, short element)- Specified by:
addAtIndex
in interfaceMutableShortList
-
addAllAtIndex
public boolean addAllAtIndex(int index, short... source)- Specified by:
addAllAtIndex
in interfaceMutableShortList
-
addAllAtIndex
- Specified by:
addAllAtIndex
in interfaceMutableShortList
-
remove
public boolean remove(short value)- Specified by:
remove
in interfaceMutableShortCollection
-
removeIf
- Specified by:
removeIf
in interfaceMutableShortCollection
-
removeAll
- Specified by:
removeAll
in interfaceMutableShortCollection
-
removeAll
public boolean removeAll(short... source)- Specified by:
removeAll
in interfaceMutableShortCollection
-
retainAll
- Specified by:
retainAll
in interfaceMutableShortCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(short... source)- Specified by:
retainAll
in interfaceMutableShortCollection
- See Also:
Collection.retainAll(Collection)
-
removeAtIndex
public short removeAtIndex(int index)- Specified by:
removeAtIndex
in interfaceMutableShortList
-
set
public short set(int index, short element)- Specified by:
set
in interfaceMutableShortList
-
swap
public void swap(int index1, int index2)- Specified by:
swap
in interfaceMutableShortList
-
with
- Specified by:
with
in interfaceMutableShortCollection
- Specified by:
with
in interfaceMutableShortList
-
without
- Specified by:
without
in interfaceMutableShortCollection
- Specified by:
without
in interfaceMutableShortList
-
withAll
- Specified by:
withAll
in interfaceMutableShortCollection
- Specified by:
withAll
in interfaceMutableShortList
-
withoutAll
- Specified by:
withoutAll
in interfaceMutableShortCollection
- Specified by:
withoutAll
in interfaceMutableShortList
-
with
-
with
-
with
-
shortIterator
Description copied from interface:ShortIterable
Returns a primitive iterator that can be used to iterate over the ShortIterable in an imperative style.- Specified by:
shortIterator
in interfaceMutableShortCollection
- Specified by:
shortIterator
in interfaceShortIterable
-
forEach
Description copied from interface:ShortIterable
Applies the ShortProcedure to each element in the ShortIterable.- Specified by:
forEach
in interfaceShortIterable
-
each
Description copied from interface:ShortIterable
A synonym for forEach.- Specified by:
each
in interfaceShortIterable
- Since:
- 7.0.
-
forEachWithIndex
- Specified by:
forEachWithIndex
in interfaceOrderedShortIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectShortToObjectFunction<? super T,? extends T> function)- Specified by:
injectInto
in interfaceShortIterable
-
injectIntoWithIndex
public <T> T injectIntoWithIndex(T injectedValue, ObjectShortIntToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoWithIndex
in interfaceOrderedShortIterable
- Specified by:
injectIntoWithIndex
in interfaceReversibleShortIterable
-
chunk
Description copied from interface:ShortIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceShortIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingShortIterable
s of sizesize
, except the last will be truncated if the elements don't divide evenly.
-
count
Description copied from interface:ShortIterable
Returns a count of the number of elements in the ShortIterable that return true for the specified predicate.- Specified by:
count
in interfaceShortIterable
-
anySatisfy
Description copied from interface:ShortIterable
Returns true if any of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceShortIterable
-
allSatisfy
Description copied from interface:ShortIterable
Returns true if all of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceShortIterable
-
noneSatisfy
Description copied from interface:ShortIterable
Returns true if none of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfy
in interfaceShortIterable
-
select
Description copied from interface:ShortIterable
Returns a new ShortIterable with all of the elements in the ShortIterable that return true for the specified predicate.- Specified by:
select
in interfaceMutableShortCollection
- Specified by:
select
in interfaceMutableShortList
- Specified by:
select
in interfaceOrderedShortIterable
- Specified by:
select
in interfaceReversibleShortIterable
- Specified by:
select
in interfaceShortIterable
- Specified by:
select
in interfaceShortList
-
select
Description copied from interface:ShortIterable
Same asShortIterable.select(ShortPredicate)
, only the results are added to the target MutableShortCollection.- Specified by:
select
in interfaceShortIterable
- Since:
- 8.1.
-
reject
Description copied from interface:ShortIterable
Returns a new ShortIterable with all of the elements in the ShortIterable that return false for the specified predicate.- Specified by:
reject
in interfaceMutableShortCollection
- Specified by:
reject
in interfaceMutableShortList
- Specified by:
reject
in interfaceOrderedShortIterable
- Specified by:
reject
in interfaceReversibleShortIterable
- Specified by:
reject
in interfaceShortIterable
- Specified by:
reject
in interfaceShortList
-
reject
Description copied from interface:ShortIterable
Same asShortIterable.reject(ShortPredicate)
, only the results are added to the target MutableShortCollection.- Specified by:
reject
in interfaceShortIterable
- Since:
- 8.1.
-
detectIfNone
- Specified by:
detectIfNone
in interfaceShortIterable
-
collect
Description copied from interface:ShortIterable
Returns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.- Specified by:
collect
in interfaceMutableShortCollection
- Specified by:
collect
in interfaceMutableShortList
- Specified by:
collect
in interfaceOrderedShortIterable
- Specified by:
collect
in interfaceReversibleShortIterable
- Specified by:
collect
in interfaceShortIterable
- Specified by:
collect
in interfaceShortList
-
collect
public <V, R extends Collection<V>> R collect(ShortToObjectFunction<? extends V> function, R target)Description copied from interface:ShortIterable
Same asShortIterable.collect(ShortToObjectFunction)
, only the results are added to the target Collection.- Specified by:
collect
in interfaceShortIterable
- Since:
- 8.1.
-
max
public short max()- Specified by:
max
in interfaceShortIterable
-
min
public short min()- Specified by:
min
in interfaceShortIterable
-
sum
public long sum()- Specified by:
sum
in interfaceShortIterable
-
dotProduct
- Specified by:
dotProduct
in interfaceShortList
-
toArray
public short[] toArray()Description copied from interface:ShortIterable
Converts the ShortIterable to a primitive short array.- Specified by:
toArray
in interfaceShortIterable
-
toArray
public short[] toArray(short[] target)Description copied from interface:ShortIterable
Converts the ShortIterable to a primitive short array. If the collection fits into the provided array it is used to store its elements and is returned from the method, otherwise a new array of the appropriate size is allocated and returned. If the iterable is empty, the target array is returned unchanged.- Specified by:
toArray
in interfaceShortIterable
-
equals
Description copied from interface:ShortList
Follows the same general contract asList.equals(Object)
. -
hashCode
public int hashCode()Description copied from interface:ShortList
Follows the same general contract asList.hashCode()
. -
appendString
Description copied from interface:PrimitiveIterable
Prints a string representation of this collection onto the givenAppendable
. Prints the string returned byPrimitiveIterable.makeString(String, String, String)
.- Specified by:
appendString
in interfacePrimitiveIterable
-
asUnmodifiable
- Specified by:
asUnmodifiable
in interfaceMutableShortCollection
- Specified by:
asUnmodifiable
in interfaceMutableShortList
-
asSynchronized
- Specified by:
asSynchronized
in interfaceMutableShortCollection
- Specified by:
asSynchronized
in interfaceMutableShortList
-
toImmutable
Description copied from interface:MutableShortList
Returns an immutable copy of this list.- Specified by:
toImmutable
in interfaceMutableShortCollection
- Specified by:
toImmutable
in interfaceMutableShortList
- Specified by:
toImmutable
in interfaceShortList
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
-
asReversed
- Specified by:
asReversed
in interfaceReversibleShortIterable
-
reverseThis
- Specified by:
reverseThis
in interfaceMutableShortList
-
sortThis
Description copied from interface:MutableShortList
Sorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThis
in interfaceMutableShortList
-
sortThis
Description copied from interface:MutableShortList
Sorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThis
in interfaceMutableShortList
-
toReversed
- Specified by:
toReversed
in interfaceMutableShortList
- Specified by:
toReversed
in interfaceReversibleShortIterable
- Specified by:
toReversed
in interfaceShortList
-
binarySearch
public int binarySearch(short value)- Specified by:
binarySearch
in interfaceShortList
-
distinct
- Specified by:
distinct
in interfaceMutableShortList
- Specified by:
distinct
in interfaceReversibleShortIterable
- Specified by:
distinct
in interfaceShortList
-
subList
- Specified by:
subList
in interfaceMutableShortList
- Specified by:
subList
in interfaceShortList
- See Also:
List.subList(int fromIndex, int toIndex)
-
zipShort
Description copied from interface:MutableShortList
Returns aMutableList
formed from thisMutableShortList
and anotherShortList
by combining corresponding elements in pairs. If one of the twoShortList
s is longer than the other, its remaining elements are ignored.- Specified by:
zipShort
in interfaceMutableShortList
- Specified by:
zipShort
in interfaceShortList
- Since:
- 9.1.
-
newEmpty
Creates a new empty ShortArrayList.- Specified by:
newEmpty
in interfaceMutableShortCollection
- Specified by:
newEmpty
in interfaceMutableShortList
- Since:
- 9.2.
-
zip
Description copied from interface:MutableShortList
Returns aMutableList
formed from thisMutableShortList
and aListIterable
by combining corresponding elements in pairs. If one of the two Lists is longer than the other, its remaining elements are ignored.- Specified by:
zip
in interfaceMutableShortList
- Specified by:
zip
in interfaceShortList
- Since:
- 9.1.
-