Package com.github.tommyettinger.ds
Class IntList
java.lang.Object
com.github.tommyettinger.ds.IntList
- All Implemented Interfaces:
Arrangeable,Ordered.OfInt,PrimitiveCollection<Integer>,PrimitiveCollection.OfInt
public class IntList
extends Object
implements PrimitiveCollection.OfInt, Ordered.OfInt, Arrangeable
A resizable, insertion-ordered int list. Primitive-backed, so it avoids the boxing that occurs with an ArrayList of Integer.
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 classAIntIterator, plusListIteratormethods, over the elements of a IntList.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 TypeFieldDescriptionint[]protected IntList.IntListIteratorprotected IntList.IntListIteratorprotected int -
Constructor Summary
ConstructorsConstructorDescriptionIntList()Creates an ordered list with a capacity of 10.IntList(boolean ordered, int capacity) Deprecated.IntList(boolean ordered, int[] array, int startIndex, int count) Deprecated.IntList is always ordered; for an unordered list useIntBagIntList(int capacity) Creates an ordered list with the specified capacity.IntList(int[] array) Creates a new list containing the elements in the specified array.IntList(int[] array, int startIndex, int count) Creates a new list containing the elements in the specified array.Creates a new list containing the elements in the given list.IntList(Ordered.OfInt other) Copies the given Ordered.OfInt into a new IntList.IntList(Ordered.OfInt 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.OfInt.IntList(IntIterator coll) Creates a new instance containing the items in the specified iterator. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int value) voidadd(int value1, int value2) voidadd(int value1, int value2, int value3) voidadd(int value1, int value2, int value3, int value4) booleanaddAll(int... array) booleanaddAll(int[] array, int offset, int length) booleanaddAll(int insertionIndex, Ordered.OfInt other, int offset, int count) Adds up tocountitems, starting fromoffset, in the Ordered.OfIntotherto this list, inserting starting atinsertionIndexin the iteration order.booleanbooleanbooleanaddAll(Ordered.OfInt other, int offset, int count) Adds up tocountitems, starting fromoffset, in the Ordered.OfIntotherto this list, inserting at the end of the iteration order.voidclear()Effectively removes all items from this IntList.booleancontains(int value) booleancontainsAll(IntList other) Returns true if this IntList contains, at least once, every item inother; otherwise returns false.div(int value) Divides each item in this IntList byvalue, stores it in this and returns it.voiddiv(int index, int value) booleanduplicateRange(int index, int count) Inserts the specified number of items at the specified index.int[]ensureCapacity(int additionalCapacity) Increases the size of the backing array to accommodate the specified number of additional items.booleanintfirst()Returns the first item.intget(int index) inthashCode()intindexOf(int value) Returns the first index in this list that contains the specified value, or -1 if it is not present.voidinsert(int index, int value) booleanisEmpty()Returns true if the list is empty.iterator()Returns a Java 8 primitive iterator over the int items in this IntList.booleanReturns true if this implementation retains order, which it does.intlastIndexOf(int value) Returns the last index in this list that contains the specified value, or -1 if it is not present.minus(int value) Takes each item in this IntList and subtractsvalue, stores it in this and returns it.voidminus(int index, int value) booleannotEmpty()Returns true if the list has one or more items, or false otherwise.order()Returns this IntList, since it is its own order.static IntListCallsparse(String, String, boolean)with brackets set to false.static IntListCreates a new collection and fills it by callingPrimitiveCollection.OfInt.addLegible(String, String, int, int)on either all ofstr(ifbracketsis false) orstrwithout its first and last chars (ifbracketsis true).static IntListCreates a new collection and fills it by callingPrimitiveCollection.OfInt.addLegible(String, String, int, int)with the given four parameters as-is.intpeek()Returns the last item.plus(int value) Addsvalueto each item in this IntList, stores it in this and returns it.voidplus(int index, int value) intpop()Removes and returns the last item.intReturns a random item from the list, or zero if the list is empty.rem(int value) Gets the remainder of each item in this IntList withvalue, stores it in this and returns it.voidrem(int index, int value) booleanremove(int value) Removes the first occurrence ofvaluefrom this IntList, returning true if anything was removed.booleanRemoves from this IntList all occurrences of any elements contained in the specified collection.intremoveAt(int index) Removes and returns the item at the specified index.booleanRemoves from this IntList 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(int find, int replace) Replaces every occurrence offindwithreplace.voidreplaceAll(com.github.tommyettinger.function.IntToIntFunction operator) Replaces each element of this list with the result of applying the given operator to that element.booleanreplaceFirst(int find, int replace) Replaces the first occurrence offindwithreplace.protected int[]resize(int newSize) booleanRemoves all items from this IntList that are not present somewhere inother, any number of times.voidreverse()Reverses the order of this Ordered in-place.voidset(int index, int value) int[]setSize(int newSize) Sets the list size, leaving any values beyond the current size undefined.int[]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(int[], int, int)in ascending order.voidsort(int from, int to) UsesArrays.sort(int[], int, int)to sort a (clamped) subrange of this collection in ascending order.voidsort(int from, int to, IntComparator c) Sorts the specified range of elements according to the order induced by the specified comparator using mergesort, orArrays.sort(int[], int, int)ifcis null.voidSorts all elements according to the order induced by the specified comparator usingIntComparators.sort(int[], int, int, IntComparator).voidswap(int first, int second) Switches the ordering of positionsfirstandsecond, without changing any items beyond that.times(int value) Multiplies each item in this IntList byvalue, stores it in this and returns it.voidtimes(int index, int value) int[]toArray()Allocates a new int array withsizeelements and fills it with the items in this.int[]toArray(int[] array) Ifarray.lengthat least equal tosize(), this copies the contents of this intoarrayand returns it; otherwise, it allocates a new int 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 IntListwith()Constructs an empty list.static IntListwith(int item) Creates a new IntList that holds only the given item, but can be resized.static IntListwith(int... varargs) Creates a new IntList that holds only the given items, but can be resized.static IntListwith(int item0, int item1) Creates a new IntList that holds only the given items, but can be resized.static IntListwith(int item0, int item1, int item2) Creates a new IntList that holds only the given items, but can be resized.static IntListwith(int item0, int item1, int item2, int item3) Creates a new IntList that holds only the given items, but can be resized.static IntListwith(int item0, int item1, int item2, int item3, int item4) Creates a new IntList that holds only the given items, but can be resized.static IntListwith(int item0, int item1, int item2, int item3, int item4, int item5) Creates a new IntList that holds only the given items, but can be resized.static IntListwith(int item0, int item1, int item2, int item3, int item4, int item5, int item6) Creates a new IntList that holds only the given items, but can be resized.static IntListwith(int item0, int item1, int item2, int item3, int item4, int item5, int item6, int item7) Creates a new IntList 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.OfInt
getOrderType, random, selectRanked, selectRankedIndexMethods inherited from interface com.github.tommyettinger.ds.PrimitiveCollection.OfInt
addAll, addAll, addDense, addDense, addLegible, addLegible, addVarargs, appendTo, appendTo, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, denseAppendTo, equalContents, forEach, removeAll, removeAll, removeAll, removeEach, removeEach, removeEach, removeIf, retainAll, retainAll, toDenseString, toDenseString, toString, toString, toString
-
Field Details
-
items
public int[] items -
size
protected int size -
iterator1
-
iterator2
-
-
Constructor Details
-
IntList
public IntList()Creates an ordered list with a capacity of 10. -
IntList
public IntList(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.
-
IntList
Deprecated.IntList is always ordered; for an unordered list useIntBagCreates an ordered list with the specified capacity.- Parameters:
ordered- ignored; for an unordered list useIntBagcapacity- Any elements added beyond this will cause the backing array to be grown.
-
IntList
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 IntList (or IntBag) to copy from
-
IntList
public IntList(int[] 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 int array to copy from
-
IntList
public IntList(int[] 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 int array to add to this liststartIndex- the first index inarrayto usecount- how many items to use fromarray
-
IntList
Deprecated.IntList is always ordered; for an unordered list useIntBagCreates 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 useIntBagarray- a non-null int array to add to this liststartIndex- the first index inarrayto usecount- how many items to use fromarray
-
IntList
Creates a new list containing the items in the specified PrimitiveCollection.OfInt.- Parameters:
coll- a primitive collection that will have its contents added to this
-
IntList
Creates a new instance containing the items in the specified iterator.- Parameters:
coll- an iterator that will have its remaining contents added to this
-
IntList
Copies the given Ordered.OfInt into a new IntList.- Parameters:
other- another Ordered.OfInt that will have its contents copied into this
-
IntList
Creates a new list by copyingcountitems from the given Ordered, starting atoffsetin that Ordered, into this.- Parameters:
other- another Ordered.OfIntoffset- 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<Integer>- Returns:
- the number of elements in this Arrangeable
-
add
public boolean add(int value) - Specified by:
addin interfacePrimitiveCollection.OfInt
-
add
public void add(int value1, int value2) -
add
public void add(int value1, int value2, int value3) -
add
public void add(int value1, int value2, int value3, int value4) -
addAll
-
addAll
-
addAll
Adds up tocountitems, starting fromoffset, in the Ordered.OfIntotherto this list, inserting at the end of the iteration order.- Parameters:
other- a non-nullOrdered.OfIntoffset- the first index inotherto usecount- how many indices inotherto use- Returns:
- true if this is modified by this call, as
addAll(IntList)does
-
addAll
Adds up tocountitems, starting fromoffset, in the Ordered.OfIntotherto this list, inserting starting atinsertionIndexin the iteration order.- Parameters:
insertionIndex- where to insert into the iteration orderother- a non-nullOrdered.OfIntoffset- the first index inotherto usecount- how many indices inotherto use- Returns:
- true if this is modified by this call, as
addAll(IntList)does
-
addAll
public boolean addAll(int... array) - Specified by:
addAllin interfacePrimitiveCollection.OfInt
-
addAll
public boolean addAll(int[] array, int offset, int length) - Specified by:
addAllin interfacePrimitiveCollection.OfInt
-
get
public int get(int index) -
set
public void set(int index, int value) -
plus
public void plus(int index, int value) -
plus
Addsvalueto each item in this IntList, 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 IntList).- Parameters:
value- each item in this will be assigneditem + value- Returns:
- this for chaining and Kotlin compatibility
-
times
public void times(int index, int value) -
times
Multiplies each item in this IntList 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 IntList).- Parameters:
value- each item in this will be assigneditem * value- Returns:
- this for chaining and Kotlin compatibility
-
minus
public void minus(int index, int value) -
minus
Takes each item in this IntList 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 IntList).- Parameters:
value- each item in this will be assigneditem - value- Returns:
- this for chaining and Kotlin compatibility
-
div
public void div(int index, int value) -
div
Divides each item in this IntList 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 IntList).- Parameters:
value- each item in this will be assigneditem / value- Returns:
- this for chaining and Kotlin compatibility
-
rem
public void rem(int index, int value) -
rem
Gets the remainder of each item in this IntList 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 IntList).- Parameters:
value- each item in this will be assigneditem % value- Returns:
- this for chaining and Kotlin compatibility
-
insert
public void insert(int index, int 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 IntList, since it is its own order. This is only here to satisfy theOrdered.OfIntinterface.- Specified by:
orderin interfaceOrdered.OfInt- Returns:
- this IntList
-
swap
public void swap(int first, int second) Description copied from interface:Ordered.OfIntSwitches the ordering of positionsfirstandsecond, without changing any items beyond that.- Specified by:
swapin interfaceArrangeable- Specified by:
swapin interfaceOrdered.OfInt- 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(int value) - Specified by:
containsin interfacePrimitiveCollection.OfInt
-
containsAll
Returns true if this IntList contains, at least once, every item inother; otherwise returns false.- Parameters:
other- an IntList- Returns:
- true if this contains every item in
other, otherwise false
-
indexOf
public int indexOf(int value) Returns the first index in this list that contains the specified value, or -1 if it is not present.- Parameters:
value- a int value to search for- Returns:
- the first index of the given value, or -1 if it is not present
-
lastIndexOf
public int lastIndexOf(int value) Returns the last index in this list that contains the specified value, or -1 if it is not present.- Parameters:
value- a int value to search for- Returns:
- the last index of the given value, or -1 if it is not present
-
remove
public boolean remove(int value) Removes the first occurrence ofvaluefrom this IntList, returning true if anything was removed. Otherwise, this returns false.- Specified by:
removein interfacePrimitiveCollection.OfInt- Parameters:
value- the value to (attempt to) remove- Returns:
- true if a value was removed, false if the IntList is unchanged
-
removeAt
public int 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(int)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.OfInt- Parameters:
start- the first index to remove, inclusiveend- the last index (after what should be removed), exclusive
-
removeAll
Removes from this IntList all occurrences of any elements contained in the specified collection.- Specified by:
removeAllin interfacePrimitiveCollection.OfInt- Parameters:
c- a primitive collection of int items to remove fully, such as another IntList or a IntDeque- Returns:
- true if this list was modified.
-
removeEach
Removes from this IntList element-wise occurrences of elements contained in the specified collection. Note that if a value is present more than once in this IntList, only one of those occurrences will be removed for each occurrence of that value inc. Ifchas the same contents as this IntList or has additional items, then removing each ofcwill clear this.- Specified by:
removeEachin interfacePrimitiveCollection.OfInt- Parameters:
c- a primitive collection of int items to remove one-by-one, such as another IntList or a IntDeque- Returns:
- true if this list was modified.
-
retainAll
Removes all items from this IntList that are not present somewhere inother, any number of times.- Specified by:
retainAllin interfacePrimitiveCollection.OfInt- Parameters:
other- a PrimitiveCollection.OfInt that contains the items that this should keep, whenever present- Returns:
- true if this IntList changed as a result of this call, otherwise false
-
replaceAll
public void replaceAll(com.github.tommyettinger.function.IntToIntFunction operator) Replaces each element of this list with the result of applying the given operator to that element.- Parameters:
operator- an IntToIntFunction (a functional interface defined in funderby)
-
replaceFirst
public boolean replaceFirst(int find, int 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(int find, int 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 int pop()Removes and returns the last item.- Returns:
- the last item, removed from this
-
peek
public int peek()Returns the last item.- Returns:
- the last item, without modifying this
-
first
public int first()Returns the first item.- Specified by:
firstin interfacePrimitiveCollection.OfInt- 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<Integer>- 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<Integer>- Returns:
- true if the list is empty, or false if it has any items
-
clear
public void clear()Effectively removes all items from this IntList. This is done simply by setting size to 0; because aintitem isn't a reference, it doesn't need to be set to null.- Specified by:
clearin interfacePrimitiveCollection<Integer>
-
shrink
public int[] 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 int[] 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 int[] 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 int[] resize(int newSize) -
sort
public void sort()Sorts this entire collection usingArrays.sort(int[], int, int)in ascending order. -
sort
public void sort(int from, int to) UsesArrays.sort(int[], 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 usingIntComparators.sort(int[], int, int, IntComparator). Ifcis null, this instead delegates tosort(), which usesArrays.sort(int[]), 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.OfInt- Parameters:
c- the comparator to determine the order of the IntList
-
sort
Sorts the specified range of elements according to the order induced by the specified comparator using mergesort, orArrays.sort(int[], int, int)ifcis null. This purely usesIntComparators.sort(int[], int, int, IntComparator), 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 IntList
-
reverse
public void reverse()Description copied from interface:Ordered.OfIntReverses the order of this Ordered in-place.- Specified by:
reversein interfaceArrangeable- Specified by:
reversein interfaceOrdered.OfInt
-
shuffle
Description copied from interface:Ordered.OfIntPseudo-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.OfInt- 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.OfInt- Parameters:
random- aRandomor a subclass, such as any from juniper- Returns:
- a randomly selected item from this, or
0if this is empty
-
toArray
public int[] toArray()Allocates a new int array withsizeelements and fills it with the items in this.- Specified by:
toArrayin interfacePrimitiveCollection.OfInt- Returns:
- a new int array with the same contents as this
-
toArray
public int[] toArray(int[] array) Ifarray.lengthat least equal tosize(), this copies the contents of this intoarrayand returns it; otherwise, it allocates a new int array that can fit all the items in this, and proceeds to copy into that and return that.- Specified by:
toArrayin interfacePrimitiveCollection.OfInt- Parameters:
array- a int 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<Integer>- Overrides:
hashCodein classObject
-
equals
- Specified by:
equalsin interfacePrimitiveCollection<Integer>- Overrides:
equalsin classObject
-
toString
-
iterator
Returns a Java 8 primitive iterator over the int items in this IntList. Iterates in order ifkeepsOrder()returns true, which it does for a IntList but not a IntBag.
This will reuse one of two iterators in this IntList; this does not allow nested iteration. UseIntListIterator(IntList)to nest iterators.- Specified by:
iteratorin interfacePrimitiveCollection<Integer>- Specified by:
iteratorin interfacePrimitiveCollection.OfInt- Returns:
- a
IntIterator; use its nextInt() 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 IntList that holds only the given item, but can be resized.- Parameters:
item- an int item- Returns:
- a new IntList that holds the given item
-
with
Creates a new IntList that holds only the given items, but can be resized.- Parameters:
item0- an int itemitem1- an int item- Returns:
- a new IntList that holds the given items
-
with
Creates a new IntList that holds only the given items, but can be resized.- Parameters:
item0- an int itemitem1- an int itemitem2- an int item- Returns:
- a new IntList that holds the given items
-
with
Creates a new IntList that holds only the given items, but can be resized.- Parameters:
item0- an int itemitem1- an int itemitem2- an int itemitem3- an int item- Returns:
- a new IntList that holds the given items
-
with
Creates a new IntList that holds only the given items, but can be resized.- Parameters:
item0- an int itemitem1- an int itemitem2- an int itemitem3- an int itemitem4- an int item- Returns:
- a new IntList that holds the given items
-
with
Creates a new IntList that holds only the given items, but can be resized.- Parameters:
item0- an int itemitem1- an int itemitem2- an int itemitem3- an int itemitem4- an int itemitem5- an int item- Returns:
- a new IntList that holds the given items
-
with
public static IntList with(int item0, int item1, int item2, int item3, int item4, int item5, int item6) Creates a new IntList that holds only the given items, but can be resized.- Parameters:
item0- an int itemitem1- an int itemitem2- an int itemitem3- an int itemitem4- an int itemitem5- an int itemitem6- an int item- Returns:
- a new IntList that holds the given items
-
with
public static IntList with(int item0, int item1, int item2, int item3, int item4, int item5, int item6, int item7) Creates a new IntList that holds only the given items, but can be resized.- Parameters:
item0- an int itemitem1- an int itemitem2- an int itemitem3- an int itemitem4- an int itemitem5- an int itemitem6- an int item- Returns:
- a new IntList that holds the given items
-
with
Creates a new IntList 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- an int varargs or int array; remember that varargs allocate- Returns:
- a new IntList 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.OfInt.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.OfInt.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
-
IntBag