|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkiwi.util.VectorUtils
This is a utility class that provides methods for performing common operations on sorted and unsorted vectors. Some of these operations are taken from set theory, while others are basic list operations.
Field Summary | |
private Comparator |
comparator
|
private MergeSort |
sorter
|
Constructor Summary | |
VectorUtils()
Construct a new VectorUtils object with the default
comparator. |
|
VectorUtils(Comparator comparator)
Construct a new VectorUtils object with the specified
comparator. |
Method Summary | |
static java.util.Vector |
append(java.util.Vector v1,
java.util.Vector v2)
Append one vector to another vector. |
java.lang.Object |
binarySearch(java.util.Vector v,
java.lang.Object o)
Perform a binary search on a presumably sorted vector. |
boolean |
compare(java.util.Vector v1,
java.util.Vector v2,
boolean sorted)
Compare two vectors. |
java.util.Vector |
difference(java.util.Vector v1,
java.util.Vector v2,
boolean sorted)
Compute the difference between two vectors. |
java.util.Vector |
intersection(java.util.Vector v1,
java.util.Vector v2,
boolean sorted)
Compute the intersection of two vectors. |
java.lang.Object |
linearSearch(java.util.Vector v,
java.lang.Object o)
Perform a linear search on a vector. |
static void |
print(java.util.Vector v)
Print the contents of a vector. |
java.lang.Object |
search(java.util.Vector v,
java.lang.Object o,
boolean sorted)
Search for an object in a vector. |
void |
setComparator(Comparator comparator)
Set the comparator to be used by the methods in this class. |
java.util.Vector |
sort(java.util.Vector v)
Sort a vector. |
java.util.Vector |
union(java.util.Vector v1,
java.util.Vector v2,
boolean sorted)
Compute the union of two vectors. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private Comparator comparator
private MergeSort sorter
Constructor Detail |
public VectorUtils()
VectorUtils
object with the default
comparator. The default comparator is the HashCodeComparator
.
HashCodeComparator
public VectorUtils(Comparator comparator)
VectorUtils
object with the specified
comparator.
comparator
- The comparator to use.Method Detail |
public void setComparator(Comparator comparator)
comparator
- The comparator to use.public static void print(java.util.Vector v)
v
- The vector to print.public java.lang.Object search(java.util.Vector v, java.lang.Object o, boolean sorted)
v
- The vector to search.o
- The object to search for.sorted
- A flag specifying whether the vector is sorted.
null
otherwise.public java.lang.Object linearSearch(java.util.Vector v, java.lang.Object o)
v
- The vector to search.o
- The object to search for.
null
otherwise.public java.lang.Object binarySearch(java.util.Vector v, java.lang.Object o)
v
- The vector to search.o
- The object to search for.
null
otherwise.public java.util.Vector sort(java.util.Vector v)
v
- The vector to sort.
v
in sorted
order.public boolean compare(java.util.Vector v1, java.util.Vector v2, boolean sorted)
v1
- The first vector.v2
- The second vector.sorted
- A flag specifying whether the vectors are sorted.
true
if the vectors are "equal" and
false
otherwise.public java.util.Vector union(java.util.Vector v1, java.util.Vector v2, boolean sorted)
v1
- The first vector.v2
- The second vector.sorted
- A flag specifying whether the vectors are sorted.
v1
and all
items in v2
that are not also in v1
.public java.util.Vector intersection(java.util.Vector v1, java.util.Vector v2, boolean sorted)
v1
- The first vector.v2
- The second vector.sorted
- A flag specifying whether the vectors are sorted.
v1
and v2
.public java.util.Vector difference(java.util.Vector v1, java.util.Vector v2, boolean sorted)
v1
- The first vector.v2
- The second vector.sorted
- A flag specifying whether the vectors are sorted.
v1
that are
not in v2
.public static java.util.Vector append(java.util.Vector v1, java.util.Vector v2)
v1
- The original vector.v2
- The vector of items to append to v1
.
v1
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |