Package com.iizix
Class IntArrayList
- java.lang.Object
- com.iizix.IntArrayList
 
- public class IntArrayList extends java.lang.ObjectClass mimicking the behavior of ArrayList with Integer without collection support.- This class is NOT thread safe. - Author:
- Christopher Mindus
 
- Field Summary- Fields - Modifier and Type - Field - Description - static int[]- EMPTYEmpty array.
 - Constructor Summary- Constructors - Constructor - Description - IntArrayList()Creates an array with an initial capacity of 16.- IntArrayList(int size)Creates an array with an initial capacity.- IntArrayList(int[] values)Creates an array with a set of values.- IntArrayList(java.util.ArrayList<java.lang.Integer> list)Creates an array from an ArrayList of Integer's.
 - Method Summary- All Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - void- add(int value)Adds a value to the end of the array.- void- add(int index, int value)Adds a value to this list at the given index- void- addAll(int[] values)Adds an array of values to the end of this array.- void- addAll(IntArrayList list)Adds an array of values to the end of this array.- void- clear()Clears the array, i.e.- boolean- contains(int value)Determines if this array contains a given value.- void- ensureCapacity(int minCapacity)Ensures that this list's capacity is at list the given value.- int- get(int index)Gets the value in the array at the given index.- int- indexOf(int value)Finds the index of a value in this array.- int- instanceCount(int value)Counts the number of times a value is represented in this array.- boolean- isEmpty()Checks if the array is empty.- int- lastIndexOf(int value)Finds the index of a value in this array from the array's tail.- int- remove(int index)Removes a value from this list- int- removeAll(int value)Removes all instances of the given value from this array.- boolean- removeValue(int value)Removes the first occurrence of a value from this array.- int- set(int index, int value)Replaces a value in this list with another value.- int- size()Returns the size of the array.- int[]- toArray()Returns a new array of the values in the array.- java.util.ArrayList<java.lang.Integer>- toArrayList()Converts the array to an ArrayList of Integer's.- java.lang.Integer[]- toObjectArray()Returns an array of Integer values of the array.- void- trimToSize()Trims this list so that it wastes no space and its capacity is equal to its size.
 
- Constructor Detail- IntArrayList- public IntArrayList() Creates an array with an initial capacity of 16.
 - IntArrayList- public IntArrayList(int size) Creates an array with an initial capacity.- Parameters:
- size- The initial capacity of the list.
 
 - IntArrayList- public IntArrayList(int[] values) Creates an array with a set of values.- Parameters:
- values- The values for the list.
 
 - IntArrayList- public IntArrayList(java.util.ArrayList<java.lang.Integer> list) Creates an array from an ArrayList of Integer's.- Parameters:
- list- The ArrayList.
- Throws:
- java.lang.NullPointerException- If any of the Integer items in the list is null.
 
 
 - Method Detail- size- public int size() Returns the size of the array.- Returns:
- The number of elements in the array.
 
 - isEmpty- public boolean isEmpty() Checks if the array is empty.- Returns:
- Whether this list is empty of elements.
 
 - clear- public void clear() Clears the array, i.e. setting its size to 0.
 - get- public int get(int index) Gets the value in the array at the given index.- Parameters:
- index- The index of the value to get.
- Returns:
- The value at the given index.
 
 - add- public void add(int value) Adds a value to the end of the array.- Parameters:
- value- The value to add to the array.
 
 - add- public void add(int index, int value)Adds a value to this list at the given index- Parameters:
- index- The index to add the value at
- value- The value to add to the list
 
 - addAll- public void addAll(int[] values) Adds an array of values to the end of this array.- Parameters:
- values- The values to add.
 
 - addAll- public void addAll(IntArrayList list) Adds an array of values to the end of this array.- Parameters:
- list- The list of values to add.
 
 - set- public int set(int index, int value)Replaces a value in this list with another value.- Parameters:
- index- The index of the value to replace.
- value- The value to replace the old value with.
- Returns:
- The old value at the given index.
 
 - remove- public int remove(int index) Removes a value from this list- Parameters:
- index- The index of the value to remove
- Returns:
- The value that was removed
 
 - removeValue- public boolean removeValue(int value) Removes the first occurrence of a value from this array.- Parameters:
- value- The value to remove.
- Returns:
- Whether the value was found and removed.
 
 - removeAll- public int removeAll(int value) Removes all instances of the given value from this array.- Parameters:
- value- The value to remove.
- Returns:
- The count of values removed.
 
 - contains- public boolean contains(int value) Determines if this array contains a given value.- Parameters:
- value- The value to find.
- Returns:
- Whether this array contains the given value.
 
 - instanceCount- public int instanceCount(int value) Counts the number of times a value is represented in this array.- Parameters:
- value- The value to count.
- Returns:
- The count of values in this array.
 
 - indexOf- public int indexOf(int value) Finds the index of a value in this array.- Parameters:
- value- The value to find.
- Returns:
- The first index whose value is the given value.
 
 - lastIndexOf- public int lastIndexOf(int value) Finds the index of a value in this array from the array's tail.- Parameters:
- value- The value to find.
- Returns:
- The last index whose value is the given value.
 
 - toArray- public int[] toArray() Returns a new array of the values in the array.- Returns:
- An array of values currently in this array.
 
 - toArrayList- public java.util.ArrayList<java.lang.Integer> toArrayList() Converts the array to an ArrayList of Integer's.- Returns:
- A new instance of an ArrayList of Integer's.
 
 - toObjectArray- public java.lang.Integer[] toObjectArray() Returns an array of Integer values of the array.- Returns:
- The array of values currently in this array as Integer's.
 
 - trimToSize- public void trimToSize() Trims this list so that it wastes no space and its capacity is equal to its size.
 - ensureCapacity- public void ensureCapacity(int minCapacity) Ensures that this list's capacity is at list the given value.- Parameters:
- minCapacity- The minimum capacity for the list.