Java 类it.unimi.dsi.fastutil.ints.Int2IntArrayMap 实例源码

项目:FirstAid    文件:GuiUtils.java   
private static void renderLine(int regen, boolean low, int yTexture, int maxHealth, int maxExtraHearts, int current, int absorption, Gui gui, boolean highlight) {
    GlStateManager.pushMatrix();
    Int2IntMap map = new Int2IntArrayMap();
    if (low) {
        for (int i = 0; i < (maxHealth + maxExtraHearts); i++)
            map.put(i, EventHandler.rand.nextInt(2));
    }

    renderMax(regen, map, maxHealth, yTexture, gui, highlight);
    if (maxExtraHearts > 0) { //for absorption
        if (maxHealth != 0) {
            GlStateManager.translate(2 + 9 * maxHealth, 0, 0);
        }
        renderMax(regen - maxHealth, map, maxExtraHearts, yTexture, gui, false); //Do not highlight absorption
    }
    GlStateManager.popMatrix();
    GlStateManager.translate(0, 0, 1);

    renderCurrentHealth(regen, map, current, yTexture, gui);

    if (absorption > 0) {
        int offset = maxHealth * 9 + (maxHealth == 0 ? 0 : 2);
        GlStateManager.translate(offset, 0, 0);
        renderAbsorption(regen - maxHealth, map, absorption, yTexture, gui);
    }
}
项目:checklistbank    文件:LookupKryoFactory.java   
@Override
public Kryo create() {
  Kryo kryo = new Kryo();
  kryo.setRegistrationRequired(true);

  // model class(es)
  kryo.register(LookupUsage.class);

  // fastutils
  kryo.register(Int2IntArrayMap.class);
  kryo.register(Int2IntOpenHashMap.class);

  // java & commons
  kryo.register(Date.class);
  kryo.register(HashMap.class);
  kryo.register(HashSet.class);
  kryo.register(ArrayList.class);
  ImmutableListSerializer.registerSerializers(kryo);

  // enums
  kryo.register(Rank.class);
  kryo.register(Kingdom.class);

  return kryo;
}
项目:gatk-protected    文件:SubsettedLikelihoodMatrix.java   
public SubsettedLikelihoodMatrix(final LikelihoodMatrix<A> matrix, final List<A> alleles) {
    this.matrix = Utils.nonNull(matrix);
    this.alleles = Utils.nonNull(alleles);
    final int[] newIndices = new IndexRange(0, alleles.size()).mapToInteger(n -> n);
    final int[] oldIndices = alleles.stream().mapToInt(matrix::indexOfAllele).toArray();
    Utils.validateArg(Arrays.stream(oldIndices).noneMatch(n -> n < 0), "All alleles must be found in likelihoods matrix");
    newToOldIndexMap = new Int2IntArrayMap(newIndices, oldIndices);
}
项目:gatk    文件:SubsettedLikelihoodMatrix.java   
public SubsettedLikelihoodMatrix(final LikelihoodMatrix<A> matrix, final List<A> alleles) {
    this.matrix = Utils.nonNull(matrix);
    this.alleles = Utils.nonNull(alleles);
    final int[] newIndices = new IndexRange(0, alleles.size()).mapToInteger(n -> n);
    final int[] oldIndices = alleles.stream().mapToInt(matrix::indexOfAllele).toArray();
    Utils.validateArg(Arrays.stream(oldIndices).noneMatch(n -> n < 0), "All alleles must be found in likelihoods matrix");
    newToOldIndexMap = new Int2IntArrayMap(newIndices, oldIndices);
}
项目:checklistbank    文件:IdGeneratorTest.java   
/**
 * key, value, key, value, ...
 * pro parte maps have the parent usageKey as key, the pro parte usage key as value
 */
private static Int2IntMap map(int ... kvs) {
  Int2IntMap m = new Int2IntArrayMap(kvs.length / 2);
  int idx = 0;
  while (idx < kvs.length) {
    m.put(kvs[idx], kvs[idx+1]);
    idx = idx + 2;
  }
  return m;
}
项目:metanome-algorithms    文件:FindCoversGenerator.java   
private IntList generateInitialOrdering(List<DifferenceSet> tempDiffSet) {

        IntList result = new IntArrayList();

        Int2IntMap counting = new Int2IntArrayMap();
        for (DifferenceSet ds : tempDiffSet) {

            int lastIndex = ds.getAttributes().nextSetBit(0);

            while (lastIndex != -1) {
                if (!counting.containsKey(lastIndex)) {
                    counting.put(lastIndex, 1);
                } else {
                    counting.put(lastIndex, counting.get(lastIndex) + 1);
                }
                lastIndex = ds.getAttributes().nextSetBit(lastIndex + 1);
            }
        }

        // TODO: Comperator und TreeMap --> Tommy
        while (true) {

            if (counting.size() == 0) {
                break;
            }

            int biggestAttribute = -1;
            int numberOfOcc = 0;
            for (int attr : counting.keySet()) {

                if (biggestAttribute < 0) {
                    biggestAttribute = attr;
                    numberOfOcc = counting.get(attr);
                    continue;
                }

                int tempOcc = counting.get(attr);
                if (tempOcc > numberOfOcc) {
                    numberOfOcc = tempOcc;
                    biggestAttribute = attr;
                } else if (tempOcc == numberOfOcc) {
                    if (biggestAttribute > attr) {
                        biggestAttribute = attr;
                    }
                }
            }

            if (numberOfOcc == 0) {
                break;
            }

            result.add(biggestAttribute);
            counting.remove(biggestAttribute);
        }

        return result;
    }
项目:metanome-algorithms    文件:FindCoversGenerator.java   
private IntList generateNextOrdering(List<DifferenceSet> next, IntList currentOrdering, int attribute) {

        IntList result = new IntArrayList();

        Int2IntMap counting = new Int2IntArrayMap();
        boolean seen = false;
        for (int i = 0; i < currentOrdering.size(); i++) {

            if (!seen) {
                if (currentOrdering.getInt(i) != attribute) {
                    continue;
                } else {
                    seen = true;
                }
            } else {

                counting.put(currentOrdering.getInt(i), 0);
                for (DifferenceSet ds : next) {

                    if (ds.getAttributes().get(currentOrdering.getInt(i))) {
                        counting.put(currentOrdering.getInt(i), counting.get(currentOrdering.getInt(i)) + 1);
                    }
                }
            }
        }

        // TODO: Comperator und TreeMap --> Tommy
        while (true) {

            if (counting.size() == 0) {
                break;
            }

            int biggestAttribute = -1;
            int numberOfOcc = 0;
            for (int attr : counting.keySet()) {

                if (biggestAttribute < 0) {
                    biggestAttribute = attr;
                    numberOfOcc = counting.get(attr);
                    continue;
                }

                int tempOcc = counting.get(attr);
                if (tempOcc > numberOfOcc) {
                    numberOfOcc = tempOcc;
                    biggestAttribute = attr;
                } else if (tempOcc == numberOfOcc) {
                    if (biggestAttribute > attr) {
                        biggestAttribute = attr;
                    }
                }
            }

            if (numberOfOcc == 0) {
                break;
            }

            result.add(biggestAttribute);
            counting.remove(biggestAttribute);
        }

        return result;
    }