|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectiitb.con.util.Sorted2DIntArray
public class Sorted2DIntArray
Sorted 2D Integer Array consists of two columns (key-value) and the values are maintained in sorted order according to the key. It is an unbound array and handles duplicate values.
Constructor Summary | |
---|---|
Sorted2DIntArray(java.nio.ByteBuffer buffer)
|
|
Sorted2DIntArray(int size)
Constructor with full specification. |
Method Summary | |
---|---|
int |
add(int value1,
int value2)
Add a value to the array, appending it after the current values. |
void |
clear()
Set the array to the empty state. |
void |
dump()
Prints the contents of the array |
void |
ensureCapacity(int min)
Ensure that the array has the capacity for at least the specified number of values. |
int[][] |
get(int value1)
Retrieve the value present at an index position in the array. |
boolean |
isValuePairExist(int value1,
int value2)
Checks if given value pair exists in the array |
static void |
main(java.lang.String[] args)
|
void |
remove(int value1)
Remove a value from the array. |
void |
set(int value1,
int value2)
Sets the values based on the index match of value1 in the array. |
void |
setSize(int count)
Sets the number of values currently present in the array. |
int |
size()
Get the number of values currently present in the array. |
java.nio.ByteBuffer |
toBuffer()
Returns the array contents as bytes in the form of ByteBuffer |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Sorted2DIntArray(java.nio.ByteBuffer buffer)
public Sorted2DIntArray(int size)
size
- number of int values initially allowed in arrayMethod Detail |
---|
public final int add(int value1, int value2)
value1
- value to be addedvalue2
- value to be added
public final void clear()
public void dump()
public final void ensureCapacity(int min)
min
- minimum capacity to be guaranteedpublic final int[][] get(int value1)
value1
- rows to be retrieved using value1
public final boolean isValuePairExist(int value1, int value2)
value1
- first column value (key)value2
- second column value
public static void main(java.lang.String[] args)
public void remove(int value1)
value1
- index of value1 to be removedpublic final void set(int value1, int value2)
value1
- value used to located the index in the arrayvalue2
- value to be setpublic void setSize(int count)
count
- number of values to be setpublic final int size()
public java.nio.ByteBuffer toBuffer()
ByteBuffer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |