@Test
    public void testTop() {
        Random r = new Random(260379);

        ArrayList<Integer> workArr = new ArrayList<Integer>();
        TreeMap<Integer, Integer> countToId = new TreeMap<Integer, Integer>(new Comparator<Integer>() {
            public int compare(Integer integer, Integer integer1) {
                return -integer.compareTo(integer1);
            }
        });
        for(int i=1; i < 200; i+=2) {
            int n;
            do {
                n = r.nextInt(10000);
            } while (countToId.containsKey(n)); // Unique count keys
            countToId.put(n, i);
            insertMultiple(workArr, i, n);
        }

        DiscreteDistribution dist = new DiscreteDistribution(toIntArray(workArr));

        IdCount[] top = dist.getTop(10);


        int j = 0;
        for(Map.Entry <Integer, Integer> e : countToId.entrySet()) {
            IdCount topEntryJ = top[j];
            assertEquals((int)e.getValue(), topEntryJ.id);
            assertEquals((int)e.getKey(), topEntryJ.count);
            j++;
            if (top.length <= j) {
                assertEquals(10, j);
                break;
            }
        }
    }