@@ -0,0 +1,2278 @@
+package de.jungblut.math.dense;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0Aimport java.util.HashSet;%0A%0Apublic final class DenseIntVector %7B%0A%0A  private final int%5B%5D vector;%0A%0A  public DenseIntVector(int%5B%5D arr) %7B%0A    // normally, we should make a deep copy%0A    this.vector = arr;%0A  %7D%0A%0A  public DenseIntVector(int size) %7B%0A    this(new int%5Bsize%5D);%0A  %7D%0A%0A  public DenseIntVector(Collection%3CInteger%3E prediction) %7B%0A    this.vector = new int%5Bprediction.size()%5D;%0A    int index = 0;%0A    for (Integer i : prediction) %7B%0A      vector%5Bindex++%5D = i;%0A    %7D%0A  %7D%0A%0A  public final int get(int index) %7B%0A    return vector%5Bindex%5D;%0A  %7D%0A%0A  public final int getLength() %7B%0A    return vector.length;%0A  %7D%0A%0A  final void set(int index, int value) %7B%0A    vector%5Bindex%5D = value;%0A  %7D%0A%0A  public final int getNumberOfDistinctElements() %7B%0A    final int length = getLength();%0A    final HashSet%3CInteger%3E set = new HashSet%3CInteger%3E(length);%0A    for (int i = 0; i %3C length; i++) %7B%0A      set.add(get(i));%0A    %7D%0A    return set.size();%0A  %7D%0A%0A  // in our %22hack%22 environment, this fast retrieval can be made because we%0A  // have%0A  // elements starting from 0 and then are%0A  // incremented. -%3E Experimental!%0A  public final int getNumberOfDistinctElementsFast() %7B%0A    int high = 0;%0A    final int length = getLength();%0A    for (int i = 0; i %3C length; i++) %7B%0A      final int j = get(i);%0A      if (high %3C j) %7B%0A        high = j;%0A      %7D%0A    %7D%0A    // +1 because of zero%0A    return high + 1;%0A  %7D%0A%0A  public int getMaxValue() %7B%0A    int maxValue = vector%5B0%5D;%0A    for (int aVector : vector) %7B%0A      if (maxValue %3C aVector) %7B%0A        maxValue = aVector;%0A      %7D%0A    %7D%0A    return maxValue;%0A  %7D%0A%0A  /*%0A   * MATH stuff%0A   */%0A%0A  public final void add(DenseIntVector v) %7B%0A    for (int i = 0; i %3C v.getLength(); i++) %7B%0A      this.set(i, this.get(i) + v.get(i));%0A    %7D%0A  %7D%0A%0A  public final int%5B%5D toArray() %7B%0A    return vector;%0A  %7D%0A%0A  public DenseIntVector slice(int length) %7B%0A    return slice(0, length);%0A  %7D%0A%0A  public DenseIntVector slice(int offset, int length) %7B%0A    DenseIntVector nv = new DenseIntVector(length - offset);%0A    int index = 0;%0A    for (int i = offset; i %3C length; i++) %7B%0A      nv.set(index++, vector%5Bi%5D);%0A    %7D%0A%0A    return nv;%0A  %7D%0A%0A  @Override%0A  public final String toString() %7B%0A    return Arrays.toString(vector);%0A  %7D%0A%0A%7D%0A

bring back the dense int vector