danger.util
Class VectorUtils

java.lang.Object
  |
  +--danger.util.VectorUtils

public final class VectorUtils
extends java.lang.Object

Vector utilities.


Method Summary
static void addAll(java.util.Vector v1, java.util.Vector v2)
          Append all the elements of the second vector to the end of the first, in order.
static int eqIndexOf(java.util.Vector vec, java.lang.Object elem)
          Search for the exact element given, compared with == (as opposed to Vector.indexOf() which uses Object.equals() for most comparisons).
static int eqRemoveElement(java.util.Vector vec, java.lang.Object elem)
          Search for and remove the exact element given, compared with == (as opposed to Vector.removeElement() which uses Object.equals() for most comparisons).
static java.util.Vector fromArray(java.lang.Object[] arr)
          Construct and return a Vector containing all the elements of the given array, in the same order.
static int insertSorted(java.util.Vector vec, java.lang.Object elem)
          Insert the given element into the given vector in sorted order, using Comparable.compareTo() for comparisons.
static int insertSorted(java.util.Vector vec, java.lang.Object elem, java.util.Comparator comp)
          Insert the given element into the given vector in sorted order, using the given Compator for comparisons.
static int insertUniqueSorted(java.util.Vector vec, java.lang.Object elem)
          Insert the given element into the given vector in sorted order, using Comparable.compareTo() for comparisons, checking for duplicates and not inserting if an equal element is already in the vector.
static int insertUniqueSorted(java.util.Vector vec, java.lang.Object elem, java.util.Comparator comp)
          Insert the given element into the given vector in sorted order, using the given Comparator for comparisons, checking for duplicates and not inserting if an equal element is already in the vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fromArray

public static java.util.Vector fromArray(java.lang.Object[] arr)
Construct and return a Vector containing all the elements of the given array, in the same order.
Parameters:
arr - non-null; the array of elements
Returns:
non-null; an appropriately-constructed Vector

eqIndexOf

public static int eqIndexOf(java.util.Vector vec,
                            java.lang.Object elem)
Search for the exact element given, compared with == (as opposed to Vector.indexOf() which uses Object.equals() for most comparisons).
Parameters:
vec - non-null; the Vector to search in
elem - null-ok; the element to look for
Returns:
the index that the element was found at, or -1 if it was not found

eqRemoveElement

public static int eqRemoveElement(java.util.Vector vec,
                                  java.lang.Object elem)
Search for and remove the exact element given, compared with == (as opposed to Vector.removeElement() which uses Object.equals() for most comparisons).
Parameters:
vec - non-null; the Vector to search in
elem - null-ok; the element to look for
Returns:
the index that the element was found at and removed from, or -1 if it was not found

insertSorted

public static int insertSorted(java.util.Vector vec,
                               java.lang.Object elem)
Insert the given element into the given vector in sorted order, using Comparable.compareTo() for comparisons. This method does not check for duplicates.
Parameters:
vec - non-null; the vector to insert into
elem - null-ok; the element to insert
Returns:
the index that the element was inserted at

insertSorted

public static int insertSorted(java.util.Vector vec,
                               java.lang.Object elem,
                               java.util.Comparator comp)
Insert the given element into the given vector in sorted order, using the given Compator for comparisons. This method does not check for duplicates.
Parameters:
vec - non-null; the vector to insert into
elem - null-ok; the element to insert
comp - null-ok; the comparator to use, or null to use Comparable.compareTo() instead of an explicit comparator
Returns:
the index that the element was inserted at

insertUniqueSorted

public static int insertUniqueSorted(java.util.Vector vec,
                                     java.lang.Object elem)
Insert the given element into the given vector in sorted order, using Comparable.compareTo() for comparisons, checking for duplicates and not inserting if an equal element is already in the vector.
Parameters:
vec - non-null; the vector to insert into
elem - null-ok; the element to insert
Returns:
the index that the element was inserted at, or ~index if the element was found and not reinserted

insertUniqueSorted

public static int insertUniqueSorted(java.util.Vector vec,
                                     java.lang.Object elem,
                                     java.util.Comparator comp)
Insert the given element into the given vector in sorted order, using the given Comparator for comparisons, checking for duplicates and not inserting if an equal element is already in the vector.
Parameters:
vec - non-null; the vector to insert into
elem - null-ok; the element to insert
comp - null-ok; the comparator to use, or null to use Comparable.compareTo() instead of an explicit comparator
Returns:
the index that the element was inserted at, or ~index if the element was found and not reinserted

addAll

public static void addAll(java.util.Vector v1,
                          java.util.Vector v2)
Append all the elements of the second vector to the end of the first, in order.
Parameters:
v1 - non-null; the vector to append to
v2 - non-null; the vector whose contents should be appended


Danger Confidential. Copyright © 2000-2003, Danger Inc.