public void testAsList() { ImmutableMultiset<String> multiset = ImmutableMultiset.of("a", "a", "b", "b", "b"); ImmutableList<String> list = multiset.asList(); assertEquals(ImmutableList.of("a", "a", "b", "b", "b"), list); assertEquals(2, list.indexOf("b")); assertEquals(4, list.lastIndexOf("b")); }
public void testAsList() { ImmutableSortedMultiset<String> multiset = ImmutableSortedMultiset.of("a", "a", "b", "b", "b"); ImmutableList<String> list = multiset.asList(); assertEquals(ImmutableList.of("a", "a", "b", "b", "b"), list); assertTrue(list instanceof ImmutableAsList); ImmutableList<String> copy = SerializableTester.reserializeAndAssert(list); assertTrue(copy instanceof ImmutableAsList); assertEquals(2, list.indexOf("b")); assertEquals(4, list.lastIndexOf("b")); }
@Override public int indexOf(@Nullable Object object) { int index = forwardList.lastIndexOf(object); return (index >= 0) ? reverseIndex(index) : -1; }