public class ArrayInt
extends java.lang.Object
ArrayList
Modifier and Type | Field and Description |
---|---|
private int[] |
array
Array of integer
|
private int |
size
Actual size
|
private boolean |
sorted
Indicates if array is sorted
|
Constructor and Description |
---|
ArrayInt()
Create a new instance of ArrayInt
|
ArrayInt(int initalSize)
Create a new instance of ArrayInt
|
Modifier and Type | Method and Description |
---|---|
void |
add(int integer)
Add an integer is the array
|
private void |
checkIndex(int index)
Check if an index is valid
|
void |
clear()
Clear the array
|
boolean |
contains(int integer)
Indicates if an integer is in the array.
|
boolean |
containsSupposeSorted(int integer)
Indicates if an integer is in the array.
|
void |
destroy()
Destroy properly the array int
|
private void |
expand(int more)
Expand, if need, the capacity
|
protected void |
finalize()
Call by garbage collector when want free some memory
Parent documentation: |
int |
getIndex(int integer)
Index of an integer or -1 if integer not in the array.
|
int |
getIndexSupposeSorted(int integer)
Index of an integer or -1 if integer not in the array.
|
int |
getInteger(int index)
Obtain an integer from the array
|
int |
getSize()
Array size
|
void |
insert(int integer,
int index)
Insert an integer to a given index
|
boolean |
isEmpty()
Indicates if array is empty
|
boolean |
isSortedFast()
Indicates if array is sorted.
|
boolean |
isSortedSlow()
Indicates if array is sorted.
|
void |
remove(int index)
remove an integer
|
void |
sort()
Sort the array.
|
void |
sortUniq()
Sort array in unique mode.
|
int[] |
toArray()
Convert in int array
|
java.lang.String |
toString()
String representation
Parent documentation: |
private int[] array
private int size
private boolean sorted
public ArrayInt()
public ArrayInt(int initalSize)
initalSize
- Initial capacityprivate void checkIndex(int index)
index
- Index checkedjava.lang.IllegalArgumentException
- if index not validprivate void expand(int more)
more
- Number of free space at least needprotected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- On issueObject.finalize()
public void add(int integer)
integer
- Integer to addpublic void clear()
public boolean contains(int integer)
integer
- Integer searchtrue
if the integer is insidepublic boolean containsSupposeSorted(int integer)
integer
- Integer searchtrue
if the integer is insidepublic void destroy()
public int getIndex(int integer)
integer
- Integer searchpublic int getIndexSupposeSorted(int integer)
integer
- Integer searchpublic int getInteger(int index)
index
- Integer indexpublic int getSize()
public void insert(int integer, int index)
integer
- Integer to insertindex
- Index where insertpublic boolean isEmpty()
true
if array is emptypublic boolean isSortedFast()
true
, its sure that the array is sorted, but if false
indicates that sorted is unknowntrue
if array is sorted. false
if not sure about sorted statuspublic boolean isSortedSlow()
isSortedFast()
but the answer is accurate, that means if false
is answer, you
are sure that the array is not sortedtrue
if array is sorted. false
if array not sortedpublic void remove(int index)
index
- Index of intger to removepublic void sort()
public void sortUniq()
public int[] toArray()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()