### Question:
LongUtils { public static Long2IntMap itemRanks(LongList results) { Long2IntMap ranks = new Long2IntOpenHashMap(results.size()); ranks.defaultReturnValue(-1); LongListIterator iter = results.listIterator(); while (iter.hasNext()) { int i = iter.nextIndex(); long val = iter.nextLong(); ranks.put(val, i); } return ranks; } private  LongUtils(); static Long2DoubleSortedMap frozenMap(Map<Long,Double> map); static LongSortedSet frozenSet(Collection<Long> longs); static LongSortedArraySet packedSet(Collection<Long> longs); static LongSortedArraySet packedSet(long... longs); static LongComparator keyValueComparator(final Long2DoubleFunction vals); static Long2DoubleMap flyweightMap(LongSet keys, LongToDoubleFunction valueFunc); static LongCollection asLongCollection(final Collection<Long> longs); static Long2DoubleMap asLong2DoubleMap(final Map<Long,Double> map); @Deprecated static Long2DoubleMap asLong2DoubleFunction(final Map<Long,Double> map); static LongList asLongList(List<Long> longs); static Long2DoubleMap constantDoubleMap(Set<Long> keys, double value); static LongSet asLongSet(@Nullable final Set<Long> longs); static LongSet asLongSet(@Nullable final Collection<Long> longs); static Long2IntMap itemRanks(LongList results); static LongSortedSet setDifference(LongSet items, LongSet exclude); static int intersectSize(LongSortedSet a, LongSortedSet b); static int intersectSize(LongSet a, LongSet b); static boolean hasNCommonItems(LongSortedSet a, LongSortedSet b, int n); static int unionSize(LongSortedSet a, LongSortedSet b); static LongSortedSet setUnion(LongSet a, LongSet b); static LongSortedSet setUnion(LongSortedSet a, LongSortedSet b); static LongSortedSet setIntersect(LongSet a, LongSet b); static LongSortedSet setIntersect(LongSortedSet a, LongSortedSet b); static LongSet randomSubset(LongSet set, int num, Random random); static LongSortedSet randomSubset(LongSet set, int num, LongSet exclude,
                                             Random rng); static Collector<T,?,Long2ObjectMap<List<E>>> mapCollector(ToLongFunction<T> kf, Function<T, E> vf);  }### Answer:
@Test public void testEmptyRanks() { assertThat(itemRanks(LongLists.EMPTY_LIST).size(), equalTo(0)); }
@Test public void testSingletonRanks() { Long2IntMap ranks = itemRanks(LongLists.singleton(1)); assertThat(ranks.keySet(), contains(1L)); assertThat(ranks, hasEntry(1L, 0)); }
@Test public void testTwoItemRanks() { Long2IntMap ranks = itemRanks(LongArrayList.wrap(new long[]{1,2})); assertThat(ranks.keySet(), containsInAnyOrder(1L, 2L)); assertThat(ranks, hasEntry(1L, 0)); assertThat(ranks, hasEntry(2L, 1)); }
@Test public void testThreeItemRanks() { Long2IntMap ranks = itemRanks(LongArrayList.wrap(new long[]{1,2,3})); assertThat(ranks.keySet(), containsInAnyOrder(1L, 2L, 3L)); assertThat(ranks, hasEntry(1L, 0)); assertThat(ranks, hasEntry(2L, 1)); assertThat(ranks, hasEntry(3L, 2)); }