Java Utililty Methods Vector

List of utility methods to do Vector

Description

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

Method

doublemedian(double[] vector)
Returns the median of the vector.
final double[] sorted = vector.clone();
Arrays.sort(sorted);
if (vector.length % 2 == 1) {
    return sorted[vector.length / 2];
return (sorted[vector.length / 2 - 1] + sorted[vector.length / 2]) / 2;
doublenormVector(List v1)
norm Vector
double result = 0.0;
for (Double aV1 : v1) {
    result = result + (aV1 * aV1);
return Math.sqrt(result);
VectorremoveDuplicateDomains(Vector s)
remove Duplicate Domains
int i = 0;
int j = 0;
boolean duplicates = false;
String str1 = "";
String str2 = "";
Vector v = new Vector();
for (i = 0; i < s.size(); i++) {
    duplicates = false;
...
VectorremoveDuplicates(Vector s)
remove Duplicates
int i = 0;
int j = 0;
boolean duplicates = false;
Vector v = new Vector();
for (i = 0; i < s.size(); i++) {
    duplicates = false;
    for (j = (i + 1); j < s.size(); j++) {
        if (s.elementAt(i).toString().equalsIgnoreCase(s.elementAt(j).toString())) {
...
voidshiftIndicies(List list, int[] indicies, int shiftVector)
shift List elements left or right.
if (indicies.length > 0) {
    Arrays.sort(indicies);
    int listSize = list.size();
    if (shiftVector > 0) {
        while (shiftVector > 0) {
            shiftVector--;
            if (indicies[indicies.length - 1] == (listSize - 1))
                break;
...
float[]vector(final float[] p2, final float[] p1)
Creates the vector p2-(minus) p1.
if (p2.length != p1.length)
    return null;
final int len = p2.length;
final float[] v = new float[len];
for (int i = 0; i < len; i++) {
    v[i] = p2[i] - p1[i];
return v;
...
voidVector2fMult(float[] a, float[] b, float[] dest)
Vectorf Mult
dest[X] = a[X] * b[X];
dest[Y] = a[Y] * b[Y];
voidVector2fNegate(float[] a, float[] dest)
Vectorf Negate
dest[X] = -a[X];
dest[Y] = -a[Y];
float[]Vector2fNew()
Vectorf New
return new float[] { 0, 0 };
voidVector2fNormalize(float[] a, float[] dest)
Vectorf Normalize
float fLen = (float) Math.sqrt((a[X] * a[X] + a[Y] * a[Y]));
if (fLen == 0)
    return;
fLen = 1.0f / fLen;
dest[X] = a[X] * fLen;
dest[Y] = a[Y] * fLen;