Java Utililty Methods Vector Union

List of utility methods to do Vector Union

Description

The list of methods to do Vector Union are organized into topic(s).

Method

VectormergeVectors(Vector v1, Vector v2)
Return a vector with entries existing in both vectors
if (v1 == null || v2 == null) {
    return null;
Vector v = new Vector();
if (v1.isEmpty() || v2.isEmpty()) {
    return v;
int size = v1.size();
...
Vectorunion(Vector a, Vector b)
union
Vector r = new Vector();
for (int i = 0; i < a.size(); i++)
    r.add(a.elementAt(i));
for (int i = 0; i < b.size(); i++)
    r.add(b.elementAt(i));
return r;
Vectorunion(Vector vectA, Vector vectB)

This method returns a Vector containing the union of the objects contained in vectA and vectB.

int threshold = 0;
if (vectA != null) {
    threshold = vectA.size();
if (vectB != null) {
    threshold += vectB.size();
if (threshold < 10) 
...
voidunionAdd(Vector vect, Object obj)

This method adds obj to vect if and only if vect does not already contain obj.

if (obj == null) {
    return;
if (vect.contains(obj)) {
    return;
vect.addElement(obj);