Package com.mckoi.util
Class BlockIntegerList.IntArrayListBlock
java.lang.Object
com.mckoi.util.IntegerListBlockInterface
com.mckoi.util.BlockIntegerList.IntArrayListBlock
- Enclosing class:
BlockIntegerList
The block that contains the actual int values of the list. This is
made public because it may be useful to derive from this class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int[]The array of int's stored in this block.protected intThe number of block entries in this list.Fields inherited from class com.mckoi.util.IntegerListBlockInterface
next, previous -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBlank protected constructor.IntArrayListBlock(int block_size) Constructs the block to a specific size. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddInt(int val) Adds an int to the block.final intbinarySearch(Object key, IndexComparator c) Considers each int a reference to another structure, and the block sorted by these structures.intThe bottom int in the list.final booleancanContain(int number) Returns true if the block has enough room to fill with the given number of integers.final voidclear()Clears the object to be re-used.final intcopyTo(int[] to, int offset) Copies all the data from this block into the given int[] array.final voidcopyTo(IntegerListBlockInterface dest_block) Copies all the data from this block into the given destination block.protected int[]getArray(boolean immutable) Returns the int[] array for this block.protected intReturns the count of int's in this block.final voidinsertIntAt(int val, int pos) Inserts an int at the given position.final intintAt(int pos) Returns the int at the given position in the array.final booleanisEmpty()Returns true if the block is empty.final booleanisFull()Returns true if the block is full.intiterativeSearch(int val) Performs an iterative search through the int values in the list.intiterativeSearch(int val, int position) Performs an iterative search from the given position to the end of the list in the block.final voidmoveTo(IntegerListBlockInterface dest_block, int dest_index, int length) Moves a set of values from the end of this block and inserts it into the given block at the destination index specified.final intremoveIntAt(int pos) Removes an Int from the specified position in the block.final intsearchFirst(int val) Assuming a sorted block, finds the first index in the block that equals the given value.final intsearchFirst(Object key, IndexComparator c) Considers each int a reference to another structure, and the block sorted by these structures.final intsearchLast(int val) Assuming a sorted block, finds the first index in the block that equals the given value.final intsearchLast(Object key, IndexComparator c) Considers each int a reference to another structure, and the block sorted by these structures.final intsetIntAt(int val, int pos) Sets an int at the given position, overwriting anything that was previously there.final intsize()Returns the number of entries in this block.inttopInt()The top int in the list.toString()Converts the block into a String.Methods inherited from class com.mckoi.util.IntegerListBlockInterface
hasChanged
-
Field Details
-
array
protected int[] arrayThe array of int's stored in this block. -
count
protected int countThe number of block entries in this list.
-
-
Constructor Details
-
IntArrayListBlock
protected IntArrayListBlock()Blank protected constructor. -
IntArrayListBlock
public IntArrayListBlock(int block_size) Constructs the block to a specific size.
-
-
Method Details
-
getArray
protected int[] getArray(boolean immutable) Returns the int[] array for this block. If 'immutable' is true then the array object is guarenteed to not be mutated. -
getArrayLength
protected int getArrayLength()Returns the count of int's in this block. -
size
public final int size()Returns the number of entries in this block.- Specified by:
sizein classIntegerListBlockInterface
-
isFull
public final boolean isFull()Returns true if the block is full.- Specified by:
isFullin classIntegerListBlockInterface
-
isEmpty
public final boolean isEmpty()Returns true if the block is empty.- Specified by:
isEmptyin classIntegerListBlockInterface
-
canContain
public final boolean canContain(int number) Returns true if the block has enough room to fill with the given number of integers.- Specified by:
canContainin classIntegerListBlockInterface
-
topInt
public int topInt()The top int in the list.- Specified by:
topIntin classIntegerListBlockInterface
-
bottomInt
public int bottomInt()The bottom int in the list.- Specified by:
bottomIntin classIntegerListBlockInterface
-
intAt
public final int intAt(int pos) Returns the int at the given position in the array.- Specified by:
intAtin classIntegerListBlockInterface
-
addInt
public final void addInt(int val) Adds an int to the block.- Specified by:
addIntin classIntegerListBlockInterface
-
removeIntAt
public final int removeIntAt(int pos) Removes an Int from the specified position in the block.- Specified by:
removeIntAtin classIntegerListBlockInterface
-
insertIntAt
public final void insertIntAt(int val, int pos) Inserts an int at the given position.- Specified by:
insertIntAtin classIntegerListBlockInterface
-
setIntAt
public final int setIntAt(int val, int pos) Sets an int at the given position, overwriting anything that was previously there. It returns the value that was previously at the element.- Specified by:
setIntAtin classIntegerListBlockInterface
-
moveTo
Moves a set of values from the end of this block and inserts it into the given block at the destination index specified. Assumes the destination block has enough room to store the set.- Specified by:
moveToin classIntegerListBlockInterface
-
copyTo
Copies all the data from this block into the given destination block.- Specified by:
copyToin classIntegerListBlockInterface
-
copyTo
public final int copyTo(int[] to, int offset) Copies all the data from this block into the given int[] array. Returns the number of 'int' values copied.- Specified by:
copyToin classIntegerListBlockInterface
-
clear
public final void clear()Clears the object to be re-used.- Specified by:
clearin classIntegerListBlockInterface
-
iterativeSearch
public int iterativeSearch(int val) Performs an iterative search through the int values in the list. If it's found the index of the value is returned, else it returns -1.- Specified by:
iterativeSearchin classIntegerListBlockInterface
-
iterativeSearch
public int iterativeSearch(int val, int position) Performs an iterative search from the given position to the end of the list in the block. If it's found the index of the value is returned, else it returns -1.- Specified by:
iterativeSearchin classIntegerListBlockInterface
-
binarySearch
Considers each int a reference to another structure, and the block sorted by these structures. The method performs a binary search.- Specified by:
binarySearchin classIntegerListBlockInterface
-
searchFirst
Considers each int a reference to another structure, and the block sorted by these structures. Finds the first index in the block that equals the given key.- Specified by:
searchFirstin classIntegerListBlockInterface
-
searchLast
Considers each int a reference to another structure, and the block sorted by these structures. Finds the first index in the block that equals the given key.- Specified by:
searchLastin classIntegerListBlockInterface
-
searchFirst
public final int searchFirst(int val) Assuming a sorted block, finds the first index in the block that equals the given value.- Specified by:
searchFirstin classIntegerListBlockInterface
-
searchLast
public final int searchLast(int val) Assuming a sorted block, finds the first index in the block that equals the given value.- Specified by:
searchLastin classIntegerListBlockInterface
-
toString
Converts the block into a String.
-