Package com.mckoi.util
Class IntegerListBlockInterface
- java.lang.Object
-
- com.mckoi.util.IntegerListBlockInterface
-
- Direct Known Subclasses:
BlockIntegerList.IntArrayListBlock
public abstract class IntegerListBlockInterface extends java.lang.ObjectA block of an AbstractBlockIntegerList. This exposes the contents of a block of the list.An IntegerListBlockInterface is a single element of a block of integers that make up some complete list of integers. A block integer list encapsulates a set of integers making up the block, and a chain to the next and previous block in the set.
- Author:
- Tobias Downer
-
-
Field Summary
Fields Modifier and Type Field Description IntegerListBlockInterfacenextThe next block in the chain.IntegerListBlockInterfacepreviousThe previous block in the chain.
-
Constructor Summary
Constructors Constructor Description IntegerListBlockInterface()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaddInt(int val)Adds an int to the block.abstract intbinarySearch(java.lang.Object key, IndexComparator c)Considers each int a reference to another structure, and the block sorted by these structures.abstract intbottomInt()The bottom int in the list.abstract booleancanContain(int number)Returns true if the block has enough room to fill with the given number of integers.abstract voidclear()Clears the object to be re-used.abstract intcopyTo(int[] to, int offset)Copies all the data from this block into the given int[] array.abstract voidcopyTo(IntegerListBlockInterface dest_block)Copies all the data from this block into the given destination block.booleanhasChanged()Returns true if this store has been modified.abstract voidinsertIntAt(int val, int pos)Inserts an int at the given position.abstract intintAt(int pos)Returns the int at the given position in the array.abstract booleanisEmpty()Returns true if the block is empty.abstract booleanisFull()Returns true if the block is full.abstract intiterativeSearch(int val)Performs an iterative search through the int values in the list.abstract intiterativeSearch(int val, int position)Performs an iterative search from the given position to the end of the list in the block.abstract 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.abstract intremoveIntAt(int pos)Removes an Int from the specified position in the block.abstract intsearchFirst(int val)Assuming a sorted block, finds the first index in the block that equals the given value.abstract intsearchFirst(java.lang.Object key, IndexComparator c)Considers each int a reference to another structure, and the block sorted by these structures.abstract intsearchLast(int val)Assuming a sorted block, finds the first index in the block that equals the given value.abstract intsearchLast(java.lang.Object key, IndexComparator c)Considers each int a reference to another structure, and the block sorted by these structures.abstract intsetIntAt(int val, int pos)Sets an int at the given position, overwriting anything that was previously there.abstract intsize()Returns the number of entries in this block.abstract inttopInt()The top int in the list.
-
-
-
Field Detail
-
next
public IntegerListBlockInterface next
The next block in the chain.
-
previous
public IntegerListBlockInterface previous
The previous block in the chain.
-
-
Method Detail
-
hasChanged
public final boolean hasChanged()
Returns true if this store has been modified. The purpose of this method is to determine if any updates need to be made to any persistant representation of this store.
-
size
public abstract int size()
Returns the number of entries in this block.
-
isFull
public abstract boolean isFull()
Returns true if the block is full.
-
isEmpty
public abstract boolean isEmpty()
Returns true if the block is empty.
-
canContain
public abstract boolean canContain(int number)
Returns true if the block has enough room to fill with the given number of integers.
-
topInt
public abstract int topInt()
The top int in the list.
-
bottomInt
public abstract int bottomInt()
The bottom int in the list.
-
intAt
public abstract int intAt(int pos)
Returns the int at the given position in the array.
-
addInt
public abstract void addInt(int val)
Adds an int to the block.
-
removeIntAt
public abstract int removeIntAt(int pos)
Removes an Int from the specified position in the block.
-
insertIntAt
public abstract void insertIntAt(int val, int pos)Inserts an int at the given position.
-
setIntAt
public abstract 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.
-
moveTo
public abstract 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. Assumes 'dest_block' is the same class as this.
-
copyTo
public abstract void copyTo(IntegerListBlockInterface dest_block)
Copies all the data from this block into the given destination block. Assumes 'dest_block' is the same class as this.
-
copyTo
public abstract 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.
-
clear
public abstract void clear()
Clears the object to be re-used.
-
iterativeSearch
public abstract 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.
-
iterativeSearch
public abstract 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.
-
binarySearch
public abstract 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.
-
searchFirst
public abstract 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.
-
searchLast
public abstract 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.
-
searchFirst
public abstract int searchFirst(int val)
Assuming a sorted block, finds the first index in the block that equals the given value.
-
searchLast
public abstract int searchLast(int val)
Assuming a sorted block, finds the first index in the block that equals the given value.
-
-