Package com.mckoi.util
Class BlockIntegerList.IntArrayListBlock
- java.lang.Object
-
- com.mckoi.util.IntegerListBlockInterface
-
- com.mckoi.util.BlockIntegerList.IntArrayListBlock
-
- Enclosing class:
- BlockIntegerList
public static class BlockIntegerList.IntArrayListBlock extends IntegerListBlockInterface
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
Fields Modifier and Type Field Description protected int[]arrayThe array of int's stored in this block.protected intcountThe number of block entries in this list.-
Fields inherited from class com.mckoi.util.IntegerListBlockInterface
next, previous
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIntArrayListBlock()Blank protected constructor.IntArrayListBlock(int block_size)Constructs the block to a specific size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInt(int val)Adds an int to the block.intbinarySearch(java.lang.Object key, IndexComparator c)Considers each int a reference to another structure, and the block sorted by these structures.intbottomInt()The bottom int in the list.booleancanContain(int number)Returns true if the block has enough room to fill with the given number of integers.voidclear()Clears the object to be re-used.intcopyTo(int[] to, int offset)Copies all the data from this block into the given int[] array.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 intgetArrayLength()Returns the count of int's in this block.voidinsertIntAt(int val, int pos)Inserts an int at the given position.intintAt(int pos)Returns the int at the given position in the array.booleanisEmpty()Returns true if the block is empty.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.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.intremoveIntAt(int pos)Removes an Int from the specified position in the block.intsearchFirst(int val)Assuming a sorted block, finds the first index in the block that equals the given value.intsearchFirst(java.lang.Object key, IndexComparator c)Considers each int a reference to another structure, and the block sorted by these structures.intsearchLast(int val)Assuming a sorted block, finds the first index in the block that equals the given value.intsearchLast(java.lang.Object key, IndexComparator c)Considers each int a reference to another structure, and the block sorted by these structures.intsetIntAt(int val, int pos)Sets an int at the given position, overwriting anything that was previously there.intsize()Returns the number of entries in this block.inttopInt()The top int in the list.java.lang.StringtoString()Converts the block into a String.-
Methods inherited from class com.mckoi.util.IntegerListBlockInterface
hasChanged
-
-
-
-
Method Detail
-
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
public final void moveTo(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. Assumes the destination block has enough room to store the set.- Specified by:
moveToin classIntegerListBlockInterface
-
copyTo
public final void copyTo(IntegerListBlockInterface dest_block)
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
public final int binarySearch(java.lang.Object key, IndexComparator c)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
public final int searchFirst(java.lang.Object key, IndexComparator c)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
public final int searchLast(java.lang.Object key, IndexComparator c)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
public java.lang.String toString()
Converts the block into a String.- Overrides:
toStringin classjava.lang.Object
-
-