Package com.github.tommyettinger.ds
Class ShortList
java.lang.Object
com.github.tommyettinger.ds.ShortList
- All Implemented Interfaces:
Arrangeable,Ordered.OfShort,PrimitiveCollection<Short>,PrimitiveCollection.OfShort,RandomAccess
- Direct Known Subclasses:
ShortBag,ShortDeque
public class ShortList
extends Object
implements PrimitiveCollection.OfShort, Ordered.OfShort, Arrangeable, RandomAccess
A resizable, insertion-ordered short list. Primitive-backed, so it avoids the boxing that occurs with an ArrayList of Short.
This tries to imitate most of the
List interface, though it can't implement it without boxing its items.
Has a primitive iterator accessible via iterator().-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAShortIterator, plusListIteratormethods, over the elements of a ShortList.Nested classes/interfaces inherited from interface com.github.tommyettinger.ds.Arrangeable
Arrangeable.ArrangeableList<T>Nested classes/interfaces inherited from interface com.github.tommyettinger.ds.PrimitiveCollection
PrimitiveCollection.OfBoolean, PrimitiveCollection.OfByte, PrimitiveCollection.OfChar, PrimitiveCollection.OfDouble, PrimitiveCollection.OfFloat, PrimitiveCollection.OfInt, PrimitiveCollection.OfLong, PrimitiveCollection.OfShort -
Field Summary
FieldsModifier and TypeFieldDescriptionshort[]protected ShortList.ShortListIteratorprotected ShortList.ShortListIteratorprotected int -
Constructor Summary
ConstructorsConstructorDescriptionCreates an ordered list with a capacity of 10.ShortList(boolean ordered, int capacity) Deprecated.ShortList(boolean ordered, short[] array, int startIndex, int count) Deprecated.ShortList is always ordered; for an unordered list useShortBagShortList(int capacity) Creates an ordered list with the specified capacity.ShortList(short[] array) Creates a new list containing the elements in the specified array.ShortList(short[] array, int startIndex, int count) Creates a new list containing the elements in the specified array.ShortList(Ordered.OfShort other) Copies the given Ordered.OfShort into a new ShortList.ShortList(Ordered.OfShort other, int offset, int count) Creates a new list by copyingcountitems from the given Ordered, starting atoffsetin that Ordered, into this.Creates a new list containing the items in the specified PrimitiveCollection.OfShort.Creates a new list containing the elements in the given list.ShortList(ShortIterator coll) Creates a new instance containing the items in the specified iterator. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(short value) voidadd(short value1, short value2) voidadd(short value1, short value2, short value3) voidadd(short value1, short value2, short value3, short value4) booleanaddAll(int insertionIndex, Ordered.OfShort other, int offset, int count) Adds up tocountitems, starting fromoffset, in the Ordered.OfShortotherto this list, inserting starting atinsertionIndexin the iteration order.booleanaddAll(short... array) booleanaddAll(short[] array, int offset, int length) booleanaddAll(Ordered.OfShort other, int offset, int count) Adds up tocountitems, starting fromoffset, in the Ordered.OfShortotherto this list, inserting at the end of the iteration order.booleanbooleanvoidclear()Effectively removes all items from this ShortList.booleancontains(short value) booleancontainsAll(ShortList other) Returns true if this ShortList contains, at least once, every item inother; otherwise returns false.voiddiv(int index, short value) div(short value) Divides each item in this ShortList byvalue, stores it in this and returns it.booleanduplicateRange(int index, int count) Inserts the specified number of items at the specified index.short[]ensureCapacity(int additionalCapacity) Increases the size of the backing array to accommodate the specified number of additional items.booleanshortfirst()Returns the first item.shortget(int index) inthashCode()intindexOf(short value) Returns the first index in this list that contains the specified value, or -1 if it is not present.voidinsert(int index, short value) booleanisEmpty()Returns true if the list is empty.iterator()Returns a Java 8 primitive iterator over the int items in this ShortList.booleanReturns true if this implementation retains order, which it does.intlastIndexOf(short value) Returns the last index in this list that contains the specified value, or -1 if it is not present.voidminus(int index, short value) minus(short value) Takes each item in this ShortList and subtractsvalue, stores it in this and returns it.booleannotEmpty()Returns true if the list has one or more items, or false otherwise.order()Returns this ShortList, since it is its own order.static ShortListCallsparse(String, String, boolean)with brackets set to false.static ShortListCreates a new collection and fills it by callingPrimitiveCollection.OfShort.addLegible(String, String, int, int)on either all ofstr(ifbracketsis false) orstrwithout its first and last chars (ifbracketsis true).static ShortListCreates a new collection and fills it by callingPrimitiveCollection.OfShort.addLegible(String, String, int, int)with the given four parameters as-is.shortpeek()Returns the last item.voidplus(int index, short value) plus(short value) Addsvalueto each item in this ShortList, stores it in this and returns it.shortpop()Removes and returns the last item.shortReturns a random item from the list, or zero if the list is empty.voidrem(int index, short value) rem(short value) Gets the remainder of each item in this ShortList withvalue, stores it in this and returns it.booleanremove(short value) Removes the first occurrence ofvaluefrom this ShortList, returning true if anything was removed.booleanRemoves from this ShortList all occurrences of any elements contained in the specified collection.shortremoveAt(int index) Removes and returns the item at the specified index.booleanRemoves from this ShortList element-wise occurrences of elements contained in the specified collection.voidremoveRange(int start, int end) Removes the items between the specified start index, inclusive, and end index, exclusive.intreplaceAll(short find, short replace) Replaces every occurrence offindwithreplace.voidreplaceAll(com.github.tommyettinger.function.ShortToShortFunction operator) Replaces each element of this list with the result of applying the given operator to that element.booleanreplaceFirst(short find, short replace) Replaces the first occurrence offindwithreplace.protected short[]resize(int newSize) booleanRemoves all items from this ShortList that are not present somewhere inother, any number of times.voidreverse()Reverses the order of this Ordered in-place.voidset(int index, short value) short[]setSize(int newSize) Sets the list size, leaving any values beyond the current size undefined.short[]shrink()Reduces the size of the backing array to the size of the actual items.voidPseudo-randomly shuffles the order of this Ordered in-place.intsize()Returns the number of elements in this Arrangeable.voidsort()Sorts this entire collection usingArrays.sort(short[], int, int)in ascending order.voidsort(int from, int to) UsesArrays.sort(short[], int, int)to sort a (clamped) subrange of this collection in ascending order.voidsort(int from, int to, ShortComparator c) Sorts the specified range of elements according to the order induced by the specified comparator using mergesort, orArrays.sort(short[], int, int)ifcis null.voidSorts all elements according to the order induced by the specified comparator usingShortComparators.sort(short[], int, int, ShortComparator).voidswap(int first, int second) Switches the ordering of positionsfirstandsecond, without changing any items beyond that.voidtimes(int index, short value) times(short value) Multiplies each item in this ShortList byvalue, stores it in this and returns it.short[]toArray()Allocates a new short array withsizeelements and fills it with the items in this.short[]toArray(short[] array) Ifarray.lengthat least equal tosize(), this copies the contents of this intoarrayand returns it; otherwise, it allocates a new short array that can fit all the items in this, and proceeds to copy into that and return that.toString()voidvoidtruncate(int newSize) Reduces the size of the list to the specified size.static ShortListwith()Constructs an empty list.static ShortListwith(short item) Creates a new ShortList that holds only the given item, but can be resized.static ShortListwith(short... varargs) Creates a new ShortList that holds only the given items, but can be resized.static ShortListwith(short item0, short item1) Creates a new ShortList that holds only the given items, but can be resized.static ShortListwith(short item0, short item1, short item2) Creates a new ShortList that holds only the given items, but can be resized.static ShortListwith(short item0, short item1, short item2, short item3) Creates a new ShortList that holds only the given items, but can be resized.static ShortListwith(short item0, short item1, short item2, short item3, short item4) Creates a new ShortList that holds only the given items, but can be resized.static ShortListwith(short item0, short item1, short item2, short item3, short item4, short item5) Creates a new ShortList that holds only the given items, but can be resized.static ShortListwith(short item0, short item1, short item2, short item3, short item4, short item5, short item6) Creates a new ShortList that holds only the given items, but can be resized.static ShortListwith(short item0, short item1, short item2, short item3, short item4, short item5, short item6, short item7) Creates a new ShortList that holds only the given items, but can be resized.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.github.tommyettinger.ds.Arrangeable
rearrange, shuffleMethods inherited from interface com.github.tommyettinger.ds.Ordered.OfShort
getOrderType, random, selectRanked, selectRankedIndexMethods inherited from interface com.github.tommyettinger.ds.PrimitiveCollection.OfShort
addAll, addAll, addDense, addDense, addLegible, addLegible, addVarargs, appendTo, appendTo, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, denseAppendTo, forEach, removeAll, removeAll, removeAll, removeEach, removeEach, removeEach, removeIf, retainAll, retainAll, toDenseString, toDenseString, toString, toString, toString
-
Field Details
-
items
public short[] items -
size
protected int size -
iterator1
-
iterator2
-
-
Constructor Details
-
ShortList
public ShortList()Creates an ordered list with a capacity of 10. -
ShortList
public ShortList(int capacity) Creates an ordered list with the specified capacity.- Parameters:
capacity- Any elements added beyond this will cause the backing array to be grown.
-
ShortList
Deprecated.ShortList is always ordered; for an unordered list useShortBagCreates an ordered list with the specified capacity.- Parameters:
ordered- ignored; for an unordered list useShortBagcapacity- Any elements added beyond this will cause the backing array to be grown.
-
ShortList
Creates a new list containing the elements in the given list. The new list will be ordered. The capacity is set to the number of elements, so any subsequent elements added will cause the backing array to be grown.- Parameters:
list- another ShortList (or ShortBag) to copy from
-
ShortList
public ShortList(short[] array) Creates a new list containing the elements in the specified array. The capacity is set to the number of elements, so any subsequent elements added will cause the backing array to be grown.- Parameters:
array- a short array to copy from
-
ShortList
public ShortList(short[] array, int startIndex, int count) Creates a new list containing the elements in the specified array. The capacity is set to the number of elements, so any subsequent elements added will cause the backing array to be grown.- Parameters:
array- a non-null short array to add to this liststartIndex- the first index inarrayto usecount- how many items to use fromarray
-
ShortList
Deprecated.ShortList is always ordered; for an unordered list useShortBagCreates a new list containing the elements in the specified array. The capacity is set to the number of elements, so any subsequent elements added will cause the backing array to be grown.- Parameters:
ordered- ignored; for an unordered list useShortBagarray- a non-null short array to add to this liststartIndex- the first index inarrayto usecount- how many items to use fromarray
-
ShortList
Creates a new list containing the items in the specified PrimitiveCollection.OfShort.- Parameters:
coll- a primitive collection that will have its contents added to this
-
ShortList
Creates a new instance containing the items in the specified iterator.- Parameters:
coll- an iterator that will have its remaining contents added to this
-
ShortList
Copies the given Ordered.OfShort into a new ShortList.- Parameters:
other- another Ordered.OfShort that will have its contents copied into this
-
ShortList
Creates a new list by copyingcountitems from the given Ordered, starting atoffsetin that Ordered, into this.- Parameters:
other- another Ordered.OfShortoffset- the first index in other's ordering to draw an item fromcount- how many items to copy from other
-
-
Method Details
-
keepsOrder
public boolean keepsOrder()Returns true if this implementation retains order, which it does.- Returns:
- true
-
size
public int size()Description copied from interface:ArrangeableReturns the number of elements in this Arrangeable. Often this is shared withCollection.size(), but isn't always.- Specified by:
sizein interfaceArrangeable- Specified by:
sizein interfacePrimitiveCollection<Short>- Returns:
- the number of elements in this Arrangeable
-
add
public boolean add(short value) - Specified by:
addin interfacePrimitiveCollection.OfShort
-
add
public void add(short value1, short value2) -
add
public void add(short value1, short value2, short value3) -
add
public void add(short value1, short value2, short value3, short value4) -
addAll
-
addAll
-
addAll
Adds up tocountitems, starting fromoffset, in the Ordered.OfShortotherto this list, inserting at the end of the iteration order.- Parameters:
other- a non-nullOrdered.OfShortoffset- the first index inotherto usecount- how many indices inotherto use- Returns:
- true if this is modified by this call, as
addAll(ShortList)does
-
addAll
Adds up tocountitems, starting fromoffset, in the Ordered.OfShortotherto this list, inserting starting atinsertionIndexin the iteration order.- Parameters:
insertionIndex- where to insert into the iteration orderother- a non-nullOrdered.OfShortoffset- the first index inotherto usecount- how many indices inotherto use- Returns:
- true if this is modified by this call, as
addAll(ShortList)does
-
addAll
public boolean addAll(short... array) - Specified by:
addAllin interfacePrimitiveCollection.OfShort
-
addAll
public boolean addAll(short[] array, int offset, int length) - Specified by:
addAllin interfacePrimitiveCollection.OfShort
-
get
public short get(int index) -
set
public void set(int index, short value) -
plus
public void plus(int index, short value) -
plus
Addsvalueto each item in this ShortList, stores it in this and returns it. The presence of this method allows Kotlin code to use the+operator (though it shouldn't be used more than once in an expression, because this method modifies this ShortList).- Parameters:
value- each item in this will be assigneditem + value- Returns:
- this for chaining and Kotlin compatibility
-
times
public void times(int index, short value) -
times
Multiplies each item in this ShortList byvalue, stores it in this and returns it. The presence of this method allows Kotlin code to use the*operator (though it shouldn't be used more than once in an expression, because this method modifies this ShortList).- Parameters:
value- each item in this will be assigneditem * value- Returns:
- this for chaining and Kotlin compatibility
-
minus
public void minus(int index, short value) -
minus
Takes each item in this ShortList and subtractsvalue, stores it in this and returns it. This is just a minor convenience in Java, but the presence of this method allows Kotlin code to use the-operator (though it shouldn't be used more than once in an expression, because this method modifies this ShortList).- Parameters:
value- each item in this will be assigneditem - value- Returns:
- this for chaining and Kotlin compatibility
-
div
public void div(int index, short value) -
div
Divides each item in this ShortList byvalue, stores it in this and returns it. The presence of this method allows Kotlin code to use the/operator (though it shouldn't be used more than once in an expression, because this method modifies this ShortList).- Parameters:
value- each item in this will be assigneditem / value- Returns:
- this for chaining and Kotlin compatibility
-
rem
public void rem(int index, short value) -
rem
Gets the remainder of each item in this ShortList withvalue, stores it in this and returns it. The presence of this method allows Kotlin code to use the%operator (though it shouldn't be used more than once in an expression, because this method modifies this ShortList).- Parameters:
value- each item in this will be assigneditem % value- Returns:
- this for chaining and Kotlin compatibility
-
insert
public void insert(int index, short value) -
duplicateRange
public boolean duplicateRange(int index, int count) Inserts the specified number of items at the specified index. The new items will have values equal to the values at those indices before the insertion, and the previous values will be pushed to after the duplicated range.- Parameters:
index- the first index to duplicatecount- how many items to duplicate
-
order
Returns this ShortList, since it is its own order. This is only here to satisfy theOrdered.OfShortinterface.- Specified by:
orderin interfaceOrdered.OfShort- Returns:
- this ShortList
-
swap
public void swap(int first, int second) Description copied from interface:Ordered.OfShortSwitches the ordering of positionsfirstandsecond, without changing any items beyond that.- Specified by:
swapin interfaceArrangeable- Specified by:
swapin interfaceOrdered.OfShort- Parameters:
first- the first position, must not be negative and must be less thanArrangeable.size()second- the second position, must not be negative and must be less thanArrangeable.size()
-
contains
public boolean contains(short value) - Specified by:
containsin interfacePrimitiveCollection.OfShort
-
containsAll
Returns true if this ShortList contains, at least once, every item inother; otherwise returns false.- Parameters:
other- an ShortList- Returns:
- true if this contains every item in
other, otherwise false
-
indexOf
public int indexOf(short value) Returns the first index in this list that contains the specified value, or -1 if it is not present.- Parameters:
value- a short value to search for- Returns:
- the first index of the given value, or -1 if it is not present
-
lastIndexOf
public int lastIndexOf(short value) Returns the last index in this list that contains the specified value, or -1 if it is not present.- Parameters:
value- a short value to search for- Returns:
- the last index of the given value, or -1 if it is not present
-
remove
public boolean remove(short value) Removes the first occurrence ofvaluefrom this ShortList, returning true if anything was removed. Otherwise, this returns false.- Specified by:
removein interfacePrimitiveCollection.OfShort- Parameters:
value- the value to (attempt to) remove- Returns:
- true if a value was removed, false if the ShortList is unchanged
-
removeAt
public short removeAt(int index) Removes and returns the item at the specified index. Note that this is equivalent toList.remove(int), but can't have that name because we also haveremove(short)that removes a value, rather than an index.- Parameters:
index- the index of the item to remove and return- Returns:
- the removed item
-
removeRange
public void removeRange(int start, int end) Removes the items between the specified start index, inclusive, and end index, exclusive. Note that this takes different arguments than some other range-related methods; this needs a start index and an end index, rather than a count of items. This matches the behavior in the JDK collections.- Specified by:
removeRangein interfaceOrdered.OfShort- Parameters:
start- the first index to remove, inclusiveend- the last index (after what should be removed), exclusive
-
removeAll
Removes from this ShortList all occurrences of any elements contained in the specified collection.- Specified by:
removeAllin interfacePrimitiveCollection.OfShort- Parameters:
c- a primitive collection of int items to remove fully, such as another ShortList or a ShortDeque- Returns:
- true if this list was modified.
-
removeEach
Removes from this ShortList element-wise occurrences of elements contained in the specified collection. Note that if a value is present more than once in this ShortList, only one of those occurrences will be removed for each occurrence of that value inc. Ifchas the same contents as this ShortList or has additional items, then removing each ofcwill clear this.- Specified by:
removeEachin interfacePrimitiveCollection.OfShort- Parameters:
c- a primitive collection of int items to remove one-by-one, such as another ShortList or a ShortDeque- Returns:
- true if this list was modified.
-
retainAll
Removes all items from this ShortList that are not present somewhere inother, any number of times.- Specified by:
retainAllin interfacePrimitiveCollection.OfShort- Parameters:
other- a PrimitiveCollection.OfShort that contains the items that this should keep, whenever present- Returns:
- true if this ShortList changed as a result of this call, otherwise false
-
replaceAll
public void replaceAll(com.github.tommyettinger.function.ShortToShortFunction operator) Replaces each element of this list with the result of applying the given operator to that element.- Parameters:
operator- a ShortToShortFunction (a functional interface defined in funderby)
-
replaceFirst
public boolean replaceFirst(short find, short replace) Replaces the first occurrence offindwithreplace. Returns true if it performed the replacement, or false if there was nothing to replace. This also returns false if find and replace are the same.- Parameters:
find- the item to search forreplace- the item to replacefindwith, if possible- Returns:
- true if this changed, or false otherwise
-
replaceAll
public int replaceAll(short find, short replace) Replaces every occurrence offindwithreplace. Returns the number of changed items, which is 0 if nothing was found or in the case that find and replace are the same.- Parameters:
find- the item to search forreplace- the item to replacefindwith, if possible- Returns:
- the number of replacements that occurred; 0 if nothing was found or replaced
-
pop
public short pop()Removes and returns the last item.- Returns:
- the last item, removed from this
-
peek
public short peek()Returns the last item.- Returns:
- the last item, without modifying this
-
first
public short first()Returns the first item.- Specified by:
firstin interfacePrimitiveCollection.OfShort- Returns:
- the first item, without modifying this
-
notEmpty
public boolean notEmpty()Returns true if the list has one or more items, or false otherwise.- Specified by:
notEmptyin interfacePrimitiveCollection<Short>- Returns:
- true if the list has one or more items, or false otherwise
-
isEmpty
public boolean isEmpty()Returns true if the list is empty.- Specified by:
isEmptyin interfacePrimitiveCollection<Short>- Returns:
- true if the list is empty, or false if it has any items
-
clear
public void clear()Effectively removes all items from this ShortList. This is done simply by setting size to 0; because ashortitem isn't a reference, it doesn't need to be set to null.- Specified by:
clearin interfacePrimitiveCollection<Short>
-
shrink
public short[] shrink()Reduces the size of the backing array to the size of the actual items. This is useful to release memory when many items have been removed, or if it is known that more items will not be added.- Returns:
items; this will be a different reference if this resized
-
trimToSize
public void trimToSize() -
ensureCapacity
public short[] ensureCapacity(int additionalCapacity) Increases the size of the backing array to accommodate the specified number of additional items. Useful before adding many items to avoid multiple backing array resizes.- Returns:
items; this will be a different reference if this resized
-
setSize
public short[] setSize(int newSize) Sets the list size, leaving any values beyond the current size undefined.- Returns:
items; this will be a different reference if this resized to a larger capacity
-
resize
protected short[] resize(int newSize) -
sort
public void sort()Sorts this entire collection usingArrays.sort(short[], int, int)in ascending order. -
sort
public void sort(int from, int to) UsesArrays.sort(short[], int, int)to sort a (clamped) subrange of this collection in ascending order.- Parameters:
from- the index of the first element (inclusive) to be sortedto- the index of the last element (exclusive) to be sorted
-
sort
Sorts all elements according to the order induced by the specified comparator usingShortComparators.sort(short[], int, int, ShortComparator). Ifcis null, this instead delegates tosort(), which usesArrays.sort(short[]), and does not always run in-place.This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. The sorting algorithm is an in-place mergesort that is significantly slower than a standard mergesort, as its running time is O(n (log n)2), but it does not allocate additional memory; as a result, it can be used as a generic sorting algorithm.
- Specified by:
sortin interfaceOrdered.OfShort- Parameters:
c- the comparator to determine the order of the ShortList
-
sort
Sorts the specified range of elements according to the order induced by the specified comparator using mergesort, orArrays.sort(short[], int, int)ifcis null. This purely usesShortComparators.sort(short[], int, int, ShortComparator), and you can see its docs for more information. This clampsfromandtoto the valid range.- Parameters:
from- the index of the first element (inclusive) to be sortedto- the index of the last element (exclusive) to be sortedc- the comparator to determine the order of the ShortList
-
reverse
public void reverse()Description copied from interface:Ordered.OfShortReverses the order of this Ordered in-place.- Specified by:
reversein interfaceArrangeable- Specified by:
reversein interfaceOrdered.OfShort
-
shuffle
Description copied from interface:Ordered.OfShortPseudo-randomly shuffles the order of this Ordered in-place. You can seedrng, the random number generator, with an identical seed to reproduce a shuffle on two Ordered with the sameArrangeable.size().- Specified by:
shufflein interfaceArrangeable- Specified by:
shufflein interfaceOrdered.OfShort- Parameters:
random- anyRandomclass, such as one from juniper
-
truncate
public void truncate(int newSize) Reduces the size of the list to the specified size. If the list is already smaller than the specified size, no action is taken. -
random
Returns a random item from the list, or zero if the list is empty.- Specified by:
randomin interfaceOrdered.OfShort- Parameters:
random- aRandomor a subclass, such as any from juniper- Returns:
- a randomly selected item from this, or
0if this is empty
-
toArray
public short[] toArray()Allocates a new short array withsizeelements and fills it with the items in this.- Specified by:
toArrayin interfacePrimitiveCollection.OfShort- Returns:
- a new short array with the same contents as this
-
toArray
public short[] toArray(short[] array) Ifarray.lengthat least equal tosize(), this copies the contents of this intoarrayand returns it; otherwise, it allocates a new short array that can fit all the items in this, and proceeds to copy into that and return that.- Specified by:
toArrayin interfacePrimitiveCollection.OfShort- Parameters:
array- a short array that will be modified if it can fitsize()items- Returns:
array, if it had sufficient size, or a new array otherwise, either with a copy of this
-
hashCode
public int hashCode()- Specified by:
hashCodein interfacePrimitiveCollection<Short>- Overrides:
hashCodein classObject
-
equals
- Specified by:
equalsin interfacePrimitiveCollection<Short>- Overrides:
equalsin classObject
-
toString
-
iterator
Returns a Java 8 primitive iterator over the int items in this ShortList. Iterates in order ifkeepsOrder()returns true, which it does for a ShortList but not a ShortBag.
This will reuse one of two iterators in this ShortList; this does not allow nested iteration. UseShortListIterator(ShortList)to nest iterators.- Specified by:
iteratorin interfacePrimitiveCollection<Short>- Specified by:
iteratorin interfacePrimitiveCollection.OfShort- Returns:
- a
ShortIterator; use its nextShort() method instead of next()
-
with
Constructs an empty list. This is usually less useful than just using the constructor, but can be handy in some code-generation scenarios when you don't know how many arguments you will have.- Returns:
- a new list containing nothing
-
with
Creates a new ShortList that holds only the given item, but can be resized.- Parameters:
item- a short item- Returns:
- a new ShortList that holds the given item
-
with
Creates a new ShortList that holds only the given items, but can be resized.- Parameters:
item0- a short itemitem1- a short item- Returns:
- a new ShortList that holds the given items
-
with
Creates a new ShortList that holds only the given items, but can be resized.- Parameters:
item0- a short itemitem1- a short itemitem2- a short item- Returns:
- a new ShortList that holds the given items
-
with
Creates a new ShortList that holds only the given items, but can be resized.- Parameters:
item0- a short itemitem1- a short itemitem2- a short itemitem3- a short item- Returns:
- a new ShortList that holds the given items
-
with
Creates a new ShortList that holds only the given items, but can be resized.- Parameters:
item0- a short itemitem1- a short itemitem2- a short itemitem3- a short itemitem4- a short item- Returns:
- a new ShortList that holds the given items
-
with
public static ShortList with(short item0, short item1, short item2, short item3, short item4, short item5) Creates a new ShortList that holds only the given items, but can be resized.- Parameters:
item0- a short itemitem1- a short itemitem2- a short itemitem3- a short itemitem4- a short itemitem5- a short item- Returns:
- a new ShortList that holds the given items
-
with
public static ShortList with(short item0, short item1, short item2, short item3, short item4, short item5, short item6) Creates a new ShortList that holds only the given items, but can be resized.- Parameters:
item0- a short itemitem1- a short itemitem2- a short itemitem3- a short itemitem4- a short itemitem5- a short itemitem6- a short item- Returns:
- a new ShortList that holds the given items
-
with
public static ShortList with(short item0, short item1, short item2, short item3, short item4, short item5, short item6, short item7) Creates a new ShortList that holds only the given items, but can be resized.- Parameters:
item0- a short itemitem1- a short itemitem2- a short itemitem3- a short itemitem4- a short itemitem5- a short itemitem6- a short item- Returns:
- a new ShortList that holds the given items
-
with
Creates a new ShortList that holds only the given items, but can be resized. This overload will only be used when an array is supplied and the type of the items requested is the component type of the array, or if varargs are used and there are 9 or more arguments.- Parameters:
varargs- a short varargs or short array; remember that varargs allocate- Returns:
- a new ShortList that holds the given items
-
parse
Callsparse(String, String, boolean)with brackets set to false.- Parameters:
str- a String that will be parsed in fulldelimiter- the delimiter between items in str- Returns:
- a new collection parsed from str
-
parse
Creates a new collection and fills it by callingPrimitiveCollection.OfShort.addLegible(String, String, int, int)on either all ofstr(ifbracketsis false) orstrwithout its first and last chars (ifbracketsis true). Each item is expected to be separated bydelimiter.- Parameters:
str- a String that will be parsed in full (depending on brackets)delimiter- the delimiter between items in strbrackets- if true, the first and last chars in str will be ignored- Returns:
- a new collection parsed from str
-
parse
Creates a new collection and fills it by callingPrimitiveCollection.OfShort.addLegible(String, String, int, int)with the given four parameters as-is.- Parameters:
str- a String that will have the given section parseddelimiter- the delimiter between items in stroffset- the first position to parse in str, inclusivelength- how many chars to parse, starting from offset- Returns:
- a new collection parsed from str
-
ShortBag