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