Find unique elements of vector.
@param x an array of strings.
@return the same values as in x but with no repetitions.
777720
public static String[] unique(String[] x) {
        HashSet<String> hash = new HashSet<>(Arrays.asList(x));

        String[] y = new String[hash.size()];

        Iterator<String> keys = hash.iterator();
        for (int i = 0; i < y.length; i++) {
            y[i] = keys.next();
        }

        return y;
    }
1269159
public double[] solveLInplace(double[] X) {
    final int n = L.length;
    X[0] /= L[0][0]; // First iteration, simplified.
    for(int k = 1; k < n; k++) {
      final double[] Lk = L[k];
      for(int i = 0; i < k; i++) {
        X[k] -= X[i] * Lk[i];
      }
      X[k] /= Lk[k];
    }
    return X;
  }
643814
public int indexOf(T x) {
    int r=Arrays.binarySearch(data,x);
    return(r>=0?r:-1);
  }
377486
public Vector select(int[] indices) {
        int newLength = indices.length;

        if (newLength == 0) {
            fail("No elements selected.");
        }

        Vector result = blankOfLength(newLength);

        for (int i = 0; i < newLength; i++) {
            result.set(i, get(indices[i]));
        }

        return result;
    }
1083293
public List<IndexHolder> getUniqueIndexHolders() {
        List<IndexHolder> result = newArrayList();

        for (IndexHolder ih : indexHoldersByName.values()) {
            if (ih.isUnique()) {
                result.add(ih);
            }
        }

        return result;
    }
951372
def _get_unique_child(xtag, eltname):
    """"""
    try:
        results = xtag.findall(eltname)
        if len(results) > 1:
            raise Exception("Multiple elements found where 0/1 expected")
        elif len(results) == 1:
            return results[0]
        else:
            return None
    except Exception:
        return None
63490
def unique(enumeration):
    """"""
    duplicates = []
    for name, member in enumeration.__members__.items():
        if name != member.name:
            duplicates.append((name, member.name))
    if duplicates:
        duplicate_names = ', '.join(
                ["%s -> %s" % (alias, name) for (alias, name) in duplicates]
                )
        raise ValueError('duplicate names found in %r: %s' %
                (enumeration, duplicate_names)
                )
    return enumeration
973781
public static boolean sameList(final Vector v, final Object[] a) {
    if (v == null || a == null || v.size() != a.length) {
      return false;
    }
    for (int i = 0; i < a.length; i++) {
      final Object o = a[i];
      if (!o.equals(v.elementAt(i))) {
        return false;
      }
    }
    return true;
  }
387475
public static List<ParameterSpace> getUniqueObjects(List<ParameterSpace> allLeaves) {
        List<ParameterSpace> unique = new ArrayList<>();
        for (ParameterSpace p : allLeaves) {
            //This isn't especially efficient, but small number of parameters in general means it's fine
            boolean found = false;
            for (ParameterSpace q : unique) {
                if (p == q) {
                    found = true;
                }
            }
            if (!found) {
                unique.add(p);
            }
        }

        return unique;
    }
1172181
function(x) {
            	var index = null, n = this.elements.length;
            	for (var i = 0; i < n; i++) {
            	    if (index === null && this.elements[i] == x) {
            		index = i + 1;
            	    }
            	}
            	return index;
                }
884425
public boolean isUniqueWithExprs(Expression[] indexExprs2) {
        if (constType != UNIQUE || (indexExprs == null) || ! indexExprs.equals(indexExprs2)) {
            return false;
        }
        return true;
    }
965673
def _maybe_repeat(self, x):
    
    if isinstance(x, list):
      assert len(x) == self.n
      return x
    else:
      return [x] * self.n
87511
public static int[] getMinIndexes (int[] values)
    {
        int min = Integer.MAX_VALUE;
        int num = 0;
        int vcount = (values == null) ? 0 : values.length;

        for (int ii=0; ii < vcount; ii++) {
            int value = values[ii];

            if (value > min) {
                // common case- stop checking things..
                continue;

            } else if (value < min) {
                // new min
                min = value;
                num = 1;

            } else {
                // another sighting of min
                num++;
            }
        }

        // now find the indexes that have min
        int[] mins = new int[num];
        for (int ii=0, pos=0; pos < num; ii++) {
            if (values[ii] == min) {
                mins[pos++] = ii;
            }
        }

        return mins;
    }
277831
public double[] permute(double[] vector) {
		double[] permuted = new double[vector.length];
		for (int i = 0; i < vector.length; i++) {
			permuted[i] = vector[randomlyPermutatedIndices[i]];
		}
		return permuted;
	}
623084
def distinct(xs):
    """"""
    # don't use collections.OrderedDict because we do support Python 2.6
    seen = set()
    return [x for x in xs if x not in seen and not seen.add(x)]
701241
public boolean contains(final OffsetType x) {
    return x.asInt() >= startInclusive().asInt() && x.asInt() <= endInclusive().asInt();
  }
604835
@Override
	public CallSequence get(int index)
	{
		if (indics == null)
		{
			size();
		}
		Pair<Integer, Integer> v = indics.get(index);

		int r = v.getFirst();

		if (r == 0)
		{
			CallSequence seq = getVars();
			CallStatement skip = new CallStatement()
			{
				public Object execute()
				{
					return Utils.VOID_VALUE;
				}

				@Override
				public String toString()
				{
					return "skip";
				}
			};

			seq.add(skip);
			return seq;

		} else
		{

			TestSequence rtests = repeat.getTests();
			int count = rtests.size();
			int[] c = new int[r];

			for (int i = 0; i < r; i++)
			{
				c[i] = count;
			}

			Permutor p = new Permutor(c);
			int[] select = null;
			for (int i = 0; i < v.getSecond(); i++)
			{
				select = p.next();
			}

			CallSequence seq = getVars();

			for (int i = 0; i < r; i++)
			{
				seq.addAll(rtests.get(select[i]));
			}
			return seq;
		}

	}