|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tivoli.twg.libs.LongValueSet
Container for a set of long values. This set is optimized for searches and various set operations, including intersection, union, difference, etc. The set is also internally sorted, and allows access to this sorted array. The class also supports optimized bulk insertion of values (which should be used instead of large numbers of single inserts).
Field Summary | |
---|---|
static long |
serialVersionUID
|
Constructor Summary | |
---|---|
LongValueSet()
Construtor for creating an initially empty set. |
|
LongValueSet(int init_size)
Constructor for creating an empty set with a given initial space allocation. |
|
LongValueSet(IntValueSet init_set)
Constructor for creating a set initialized by an IntValueSet |
|
LongValueSet(long[] init_values,
int start_index,
int length)
Constructor for creating a set initialized with a given range within an array of integers. |
|
LongValueSet(LongValueSet init_set)
Constructor for creating a set initialized by another set |
Method Summary | |
---|---|
long[] |
AccessValues()
Access internal array containing values in set (read-only) |
boolean |
contains(LongValueSet s1)
Test if all members of a given set are contained in this set. |
boolean |
containsValue(long val)
Test if value is contained in this set. |
static LongValueSet |
Difference(LongValueSet s1,
LongValueSet s2)
Return LongValueSet equal to difference of set s1 from s2. |
static int |
DifferenceOfArrayFromArray(long[] a1,
int a1_start,
int a1_len,
long[] a2,
int a2_start,
int a2_len)
Produce difference of two sorted integer arrays (a1-a2), and save in a1 |
static long[] |
DifferenceOfArrays(long[] a1,
int a1_start,
int a1_len,
long[] a2,
int a2_start,
int a2_len)
Produce difference of two sorted long arrays (a1-a2) |
static long[] |
DifferenceOfArrays(long[] a1,
int a1_len,
long[] a2,
int a2_len)
Produce difference of two sorted long arrays (a1-a2) |
boolean |
DifferenceSet(LongValueSet s1)
Subtract given set from set, and save result as new value for set. |
static int |
DropDuplicates(long[] valset,
int start,
int length)
Drop duplicate values in a sorted array |
boolean |
equals(java.lang.Object obj)
Compare the value of the LongValueSet with another LongValueSet |
int |
Find(long val)
Return index of given value in set, or -1 if not in set |
static int |
Find(long val,
long[] valset,
int valset_begin,
int valset_len)
Return index of given value in sorted range of array, or -1 if not in range |
long |
GetValue(int n)
Return nth element of set |
long[] |
GetValues()
Return array containing copy of all values in set. |
int |
hashCode()
Returns a hash code value for the object |
boolean |
InsertArray(long[] val,
int start,
int length)
Insert an array of values into set. |
boolean |
InsertSet(LongValueSet insset)
Insert LongValueSet into set. |
boolean |
InsertValue(long val)
Insert a single value into the set. |
static LongValueSet |
Intersect(LongValueSet s1,
LongValueSet s2)
Return LongValueSet equal to intersection of set s1 and s2. |
static int |
IntersectArrayIntoArray(long[] a1,
int a1_start,
int a1_len,
long[] a2,
int a2_start,
int a2_len)
Intersect two sorted arrays, and store result in first array |
static long[] |
IntersectArrays(long[] a1,
int a1_start,
int a1_len,
long[] a2,
int a2_start,
int a2_len)
Produce intersection of two sorted integer arrays. |
static long[] |
IntersectArrays(long[] a1,
int a1_len,
long[] a2,
int a2_len)
Produce intersection of two sorted integer arrays. |
boolean |
IntersectSet(LongValueSet s1)
Intersect set with given set, and save result as new value for set. |
int |
Length()
Return length of set |
boolean |
RemoveArray(long[] val,
int start,
int length)
Remove an array of values from set. |
boolean |
RemoveValue(long val)
Remove value from set, if present. |
void |
reset()
Empty the contents of the set. |
void |
setEqual(LongValueSet s1)
Set set contents equal to given set |
static void |
Sort(long[] valset,
int start,
int length)
Sort a given array of integers, using quicksort |
void |
sortValues()
Sort values, if needed. |
static boolean |
TestIfSorted(long[] valset,
int start,
int length)
Test if a range in an array is already sorted |
static boolean |
TestIfSortedAndUnique(long[] valset,
int start,
int length)
Test if a range in an array is sorted with no duplicates |
java.lang.String |
toString()
String representation method (for debug) |
static LongValueSet |
Union(LongValueSet s1,
LongValueSet s2)
Return LongValueSet equal to union of two LongValueSets |
static long[] |
UnionArrays(long[] a1,
int a1_start,
int a1_len,
long[] a2,
int a2_start,
int a2_len)
Produce union of two sorted integer arrays. |
static long[] |
UnionArrays(long[] a1,
int a1_len,
long[] a2,
int a2_len)
Produce union of two sorted integer arrays. |
void |
unsortedInsertValue(long val)
Unsorted insert : quick way to add value without causing incremental sort. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final long serialVersionUID
Constructor Detail |
public LongValueSet()
public LongValueSet(int init_size)
init_size
- - initial set space allocation (array size)public LongValueSet(long[] init_values, int start_index, int length)
init_values
- - array containing initial valuesstart_index
- - index of start of values in arraylength
- - number of valuespublic LongValueSet(LongValueSet init_set)
init_set
- - set to use for initializationpublic LongValueSet(IntValueSet init_set)
init_set
- - set to use for initializationMethod Detail |
public boolean InsertValue(long val)
val
- - value to be inserted
public void unsortedInsertValue(long val)
val
- - value to be insertedpublic void sortValues()
public boolean InsertArray(long[] val, int start, int length)
val
- - array of valuesstart
- - index of start of range of valueslength
- - length of range of values to be inserted
public boolean InsertSet(LongValueSet insset)
insset
- - LongValueSet to be inserted
public boolean RemoveValue(long val)
val
- - value to be removed
public boolean RemoveArray(long[] val, int start, int length)
val
- - array of valuesstart
- - index of start of range of valueslength
- - length of range of values to be removed
public static LongValueSet Union(LongValueSet s1, LongValueSet s2)
s1
- - first LongValueSets2
- - second LongValueSet
public boolean IntersectSet(LongValueSet s1)
s1
- - set to be intersected with
public static LongValueSet Intersect(LongValueSet s1, LongValueSet s2)
s1
- - first LongValueSets2
- - second LongValueSet
public boolean DifferenceSet(LongValueSet s1)
s1
- - set to be subtracted
public static LongValueSet Difference(LongValueSet s1, LongValueSet s2)
s1
- - first LongValueSets2
- - second LongValueSet
public int Find(long val)
val
- - value to be found in setpublic static final int Find(long val, long[] valset, int valset_begin, int valset_len)
val
- - value to be found in setvalset
- - array containing sorted values to be searchedvalset_begin
- - beginning of range in valsetvalset_len
- - length of range in valsetpublic final int Length()
public final long GetValue(int n) throws java.lang.ArrayIndexOutOfBoundsException
n
- - index (base 0) of element to be returned
java.lang.ArrayIndexOutOfBoundsException
- if invalid indexpublic final long[] GetValues()
public final long[] AccessValues()
public static final void Sort(long[] valset, int start, int length)
valset
- - Array to be sortedstart
- - index of start of data to be sortedlength
- - length of data to be sortedpublic static final boolean TestIfSorted(long[] valset, int start, int length)
valset
- - array containing valuesstart
- - start of range to testlength
- - length of range to test
public static final boolean TestIfSortedAndUnique(long[] valset, int start, int length)
valset
- - array containing valuesstart
- - start of range to testlength
- - length of range to test
public static final long[] UnionArrays(long[] a1, int a1_len, long[] a2, int a2_len)
a1
- - first sorted arraya1_len
- - length of valid elements in first arraya2
- - second sorted arraya2_len
- - length of valid elements in second array
public static final long[] UnionArrays(long[] a1, int a1_start, int a1_len, long[] a2, int a2_start, int a2_len)
a1
- - first sorted arraya1_start
- - index of start of sorted arraya1_len
- - length of valid elements in first arraya2
- - second sorted arraya2_start
- - index of start of sorted arraya2_len
- - length of valid elements in second array
public static final long[] IntersectArrays(long[] a1, int a1_len, long[] a2, int a2_len)
a1
- - first sorted arraya1_len
- - length of valid elements in first arraya2
- - second sorted arraya2_len
- - length of valid elements in second array
public static final long[] IntersectArrays(long[] a1, int a1_start, int a1_len, long[] a2, int a2_start, int a2_len)
a1
- - first sorted arraya1_start
- - index of start of first sorted arraya1_len
- - length of valid elements in first arraya2
- - second sorted arraya2_len
- - length of valid elements in second array
public static final int IntersectArrayIntoArray(long[] a1, int a1_start, int a1_len, long[] a2, int a2_start, int a2_len)
a1
- - first sorted arraya1_start
- - index of start of sorted dataa1_len
- - length of valid elements in first arraya2
- - second sorted arraya2_start
- - index of start of sorted dataa2_len
- - length of valid elements in second array
public static final long[] DifferenceOfArrays(long[] a1, int a1_len, long[] a2, int a2_len)
a1
- - first sorted arraya1_len
- - length of valid elements in first arraya2
- - second sorted arraya2_len
- - length of valid elements in second array
public static final long[] DifferenceOfArrays(long[] a1, int a1_start, int a1_len, long[] a2, int a2_start, int a2_len)
a1
- - first sorted arraya1_start
- - start of valid elements in first arraya1_len
- - length of valid elements in first arraya2
- - second sorted arraya2_start
- - start of valid elements in second arraya2_len
- - length of valid elements in second array
public static final int DifferenceOfArrayFromArray(long[] a1, int a1_start, int a1_len, long[] a2, int a2_start, int a2_len)
a1
- - first sorted arraya1_start
- - start of valid elements in first arraya1_len
- - length of valid elements in first arraya2
- - second sorted arraya2_start
- - start of valid elements in second arraya2_len
- - length of valid elements in second array
public static final int DropDuplicates(long[] valset, int start, int length)
valset
- - array containing sorted valuesstart
- - index of start of sorted valueslength
- - length of range of sorted values
public int hashCode()
public boolean equals(java.lang.Object obj)
obj
- - object to be compared with
public boolean contains(LongValueSet s1)
s1
- - set to be checked
public boolean containsValue(long val)
val
- - value to be checked
public void reset()
public void setEqual(LongValueSet s1)
s1
- - set to be copiedpublic java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |