Java Vector removeDuplicates(Vector s)

Here you can find the source of removeDuplicates(Vector s)

Description

remove Duplicates

License

Apache License

Declaration

public static Vector removeDuplicates(Vector s) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    public static Vector removeDuplicates(Vector s) {
        int i = 0;
        int j = 0;
        boolean duplicates = false;

        Vector v = new Vector();

        for (i = 0; i < s.size(); i++) {
            duplicates = false;/* w  ww.  jav  a2  s .com*/
            for (j = (i + 1); j < s.size(); j++) {
                if (s.elementAt(i).toString().equalsIgnoreCase(s.elementAt(j).toString())) {
                    duplicates = true;
                }

            }
            if (duplicates == false) {
                v.addElement(s.elementAt(i).toString().trim());
            }

        }

        return v;
    }

    public static Vector removeDuplicates(Vector a, Vector b) {

        int i = 0;
        int j = 0;
        boolean present = true;
        Vector v = new Vector();

        for (i = 0; i < a.size(); i++) {
            present = false;
            for (j = 0; j < b.size(); j++) {
                if (a.elementAt(i).toString().equalsIgnoreCase(b.elementAt(j).toString())) {
                    present = true;
                }
            }
            if (!(present)) {
                v.addElement(a.elementAt(i));
            }
        }

        return v;
    }
}

Related

  1. hasDuplicates(Vector v)
  2. isContained(Object obj, Vector vect)
  3. median(double[] vector)
  4. normVector(List v1)
  5. removeDuplicateDomains(Vector s)
  6. shiftIndicies(List list, int[] indicies, int shiftVector)
  7. vector(final float[] p2, final float[] p1)
  8. Vector2fMult(float[] a, float[] b, float[] dest)
  9. Vector2fNegate(float[] a, float[] dest)