|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tivoli.twg.libs.DoubleValueSet
Container for a set of double 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 | |
---|---|
DoubleValueSet()
Construtor for creating an initially empty set. |
|
DoubleValueSet(double[] init_values,
int start_index,
int length)
Constructor for creating a set initialized with a given range within an array of integers. |
|
DoubleValueSet(DoubleValueSet init_set)
Constructor for creating a set initialized by another set |
|
DoubleValueSet(int init_size)
Constructor for creating an empty set with a given initial space allocation. |
Method Summary | |
---|---|
double[] |
AccessValues()
Access internal array containing values in set (read-only) |
boolean |
contains(DoubleValueSet s1)
Test if all members of a given set are contained in this set. |
static DoubleValueSet |
Difference(DoubleValueSet s1,
DoubleValueSet s2)
Return DoubleValueSet equal to difference of set s1 from s2. |
static int |
DifferenceOfArrayFromArray(double[] a1,
int a1_start,
int a1_len,
double[] a2,
int a2_start,
int a2_len)
Produce difference of two sorted integer arrays (a1-a2), and save in a1 |
static double[] |
DifferenceOfArrays(double[] a1,
int a1_len,
double[] a2,
int a2_len)
Produce difference of two sorted double arrays (a1-a2) |
static double[] |
DifferenceOfArrays(double[] a1,
int a1_start,
int a1_len,
double[] a2,
int a2_start,
int a2_len)
Produce difference of two sorted double arrays (a1-a2) |
boolean |
DifferenceSet(DoubleValueSet s1)
Subtract given set from set, and save result as new value for set. |
static int |
DropDuplicates(double[] valset,
int start,
int length)
Drop duplicate values in a sorted array |
boolean |
equals(java.lang.Object obj)
Compare the value of the DoubleValueSet with another DoubleValueSet |
int |
Find(double val)
Return index of given value in set, or -1 if not in set |
static int |
Find(double val,
double[] valset,
int valset_begin,
int valset_len)
Return index of given value in sorted range of array, or -1 if not in range |
double |
GetValue(int n)
Return nth element of set |
double[] |
GetValues()
Return array containing copy of all values in set. |
int |
hashCode()
Returns a hash code value for the object |
boolean |
InsertArray(double[] val,
int start,
int length)
Insert an array of values into set. |
boolean |
InsertSet(DoubleValueSet insset)
Insert DoubleValueSet into set. |
boolean |
InsertValue(double val)
Insert a single value into the set. |
static DoubleValueSet |
Intersect(DoubleValueSet s1,
DoubleValueSet s2)
Return DoubleValueSet equal to intersection of set s1 and s2. |
static int |
IntersectArrayIntoArray(double[] a1,
int a1_start,
int a1_len,
double[] a2,
int a2_start,
int a2_len)
Intersect two sorted arrays, and store result in first array |
static double[] |
IntersectArrays(double[] a1,
int a1_len,
double[] a2,
int a2_len)
Produce intersection of two sorted integer arrays. |
static double[] |
IntersectArrays(double[] a1,
int a1_start,
int a1_len,
double[] a2,
int a2_start,
int a2_len)
Produce intersection of two sorted integer arrays. |
boolean |
IntersectSet(DoubleValueSet s1)
Intersect set with given set, and save result as new value for set. |
int |
Length()
Return length of set |
boolean |
RemoveArray(double[] val,
int start,
int length)
Remove an array of values from set. |
boolean |
RemoveValue(double val)
Remove value from set, if present. |
void |
reset()
Empty the contents of the set. |
void |
setEqual(DoubleValueSet s1)
Set set contents equal to given set |
static void |
Sort(double[] valset,
int start,
int length)
Sort a given array of integers, using quicksort |
void |
sortValues()
Sort values, if needed. |
static boolean |
TestIfSorted(double[] valset,
int start,
int length)
Test if a range in an array is already sorted |
static boolean |
TestIfSortedAndUnique(double[] 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 DoubleValueSet |
Union(DoubleValueSet s1,
DoubleValueSet s2)
Return DoubleValueSet equal to union of two DoubleValueSets |
static double[] |
UnionArrays(double[] a1,
int a1_len,
double[] a2,
int a2_len)
Produce union of two sorted integer arrays. |
static double[] |
UnionArrays(double[] a1,
int a1_start,
int a1_len,
double[] a2,
int a2_start,
int a2_len)
Produce union of two sorted integer arrays. |
void |
unsortedInsertValue(double 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 DoubleValueSet()
public DoubleValueSet(int init_size)
init_size
- - initial set space allocation (array size)public DoubleValueSet(double[] init_values, int start_index, int length)
init_values
- - array containing initial valuesstart_index
- - index of start of values in arraylength
- - number of valuespublic DoubleValueSet(DoubleValueSet init_set)
init_set
- - set to use for initializationMethod Detail |
public boolean InsertValue(double val)
val
- - value to be inserted
public void unsortedInsertValue(double val)
val
- - value to be insertedpublic void sortValues()
public boolean InsertArray(double[] 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(DoubleValueSet insset)
insset
- - DoubleValueSet to be inserted
public boolean RemoveValue(double val)
val
- - value to be removed
public boolean RemoveArray(double[] 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 DoubleValueSet Union(DoubleValueSet s1, DoubleValueSet s2)
s1
- - first DoubleValueSets2
- - second DoubleValueSet
public boolean IntersectSet(DoubleValueSet s1)
s1
- - set to be intersected with
public static DoubleValueSet Intersect(DoubleValueSet s1, DoubleValueSet s2)
s1
- - first DoubleValueSets2
- - second DoubleValueSet
public boolean DifferenceSet(DoubleValueSet s1)
s1
- - set to be subtracted
public static DoubleValueSet Difference(DoubleValueSet s1, DoubleValueSet s2)
s1
- - first DoubleValueSets2
- - second DoubleValueSet
public final int Find(double val)
val
- - value to be found in setpublic static final int Find(double val, double[] 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 double GetValue(int n) throws java.lang.ArrayIndexOutOfBoundsException
n
- - index (base 0) of element to be returned
java.lang.ArrayIndexOutOfBoundsException
- if invalid indexpublic final double[] GetValues()
public final double[] AccessValues()
public static final void Sort(double[] 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(double[] valset, int start, int length)
valset
- - array containing valuesstart
- - start of range to testlength
- - length of range to test
public static final boolean TestIfSortedAndUnique(double[] valset, int start, int length)
valset
- - array containing valuesstart
- - start of range to testlength
- - length of range to test
public static final double[] UnionArrays(double[] a1, int a1_len, double[] 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 double[] UnionArrays(double[] a1, int a1_start, int a1_len, double[] 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 double[] IntersectArrays(double[] a1, int a1_len, double[] 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 double[] IntersectArrays(double[] a1, int a1_start, int a1_len, double[] 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(double[] a1, int a1_start, int a1_len, double[] 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 double[] DifferenceOfArrays(double[] a1, int a1_len, double[] 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 double[] DifferenceOfArrays(double[] a1, int a1_start, int a1_len, double[] 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(double[] a1, int a1_start, int a1_len, double[] 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(double[] 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(DoubleValueSet s1)
s1
- - set to be checked
public void reset()
public void setEqual(DoubleValueSet 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 |