Java Utililty Methods Vector to

List of utility methods to do Vector to

Description

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

Method

String[]toArray(Vector v)
Convert the given Vector to a String array.
if (v == null)
    return null;
String[] result = new String[v.size()];
v.copyInto(result);
return result;
EnumerationtoEnumeration(Vector options)
Returns the option descriptions as an enumeration.
return options.elements();
HashSettoHashSet(Vector vector)
to Hash Set
HashSet set = new HashSet();
for (int i = 0, count = vector.size(); i < count; i++) {
    set.add(vector.elementAt(i));
return set;
HashSettoHashSetD(Vector vec)
to Hash Set D
HashSet<Double> hashSet = new HashSet<Double>();
for (Double s : vec) {
    hashSet.add(s);
return hashSet;
int[]toIntArray(Vector vec)
to Int Array
int size = vec.size();
int[] array = new int[size];
for (int i = 0; i < size; i++)
    array[i] = Integer.parseInt(vec.elementAt(i).toString());
return array;
int[]toIntArray(Vector vect)
Creates a int array from a vector.
if (vect != null && vect.size() > 0) {
    int[] array = new int[vect.size()];
    for (int i = array.length - 1; i >= 0; i--) {
        array[i] = vect.elementAt(i).intValue();
    return array;
} else {
    return new int[0]; 
...
voidtoPercent(Vector members, HashMap mapMemberToValue)
Turns the mapped values into relative values (percentages) for easy use by the general topOrBottom function.
double total = 0;
int numMembers = members.size();
for (int i = 0; i < numMembers; i++) {
    Object o = mapMemberToValue.get(members.elementAt(i));
    if (o instanceof Number) {
        total += ((Number) o).doubleValue();
for (int i = 0; i < numMembers; i++) {
    Object member = members.elementAt(i);
    Object o = mapMemberToValue.get(member);
    if (o instanceof Number) {
        double d = ((Number) o).doubleValue();
        mapMemberToValue.put(member, new Double(d / total * 100));
double[]vector2doubles(Vector _v)

Turns vector of strings into a double array.

int tamanio = _v.size();
double[] toRet = new double[tamanio];
for (int i = 0; i < tamanio; ++i) {
    toRet[i] = Double.parseDouble((String) _v.elementAt(i));
return toRet;
intvectorToColor(float x, float y, float z)
This method transforms given vector's coordinates into ARGB color (A is always = 255).
int r = Math.round(255 * (x + 1f) / 2f);
int g = Math.round(255 * (y + 1f) / 2f);
int b = Math.round(255 * (z + 1f) / 2f);
return (255 << 24) + (r << 16) + (g << 8) + b;
double[]vectorTolatLonDegrees(double X, double Y, double Z)
vector Tolat Lon Degrees
return_coordinates[0] = RadsToDegrees(Math.atan2(Y, X)); 
double finalHypotenuse = Math.sqrt(X * X + Y * Y);
return_coordinates[1] = RadsToDegrees(Math.atan2(Z, finalHypotenuse)); 
return return_coordinates;