public void testCreate() { TreeMultiset<String> multiset = TreeMultiset.create(); multiset.add("foo", 2); multiset.add("bar"); assertEquals(3, multiset.size()); assertEquals(2, multiset.count("foo")); assertEquals(Ordering.natural(), multiset.comparator()); assertEquals("[bar, foo x 2]", multiset.toString()); }
public void testElementSetSubsetRemove() { TreeMultiset<String> ms = TreeMultiset.create(); ms.add("a", 1); ms.add("b", 3); ms.add("c", 2); ms.add("d", 1); ms.add("e", 3); ms.add("f", 2); SortedSet<String> elementSet = ms.elementSet(); ASSERT.that(elementSet).has().exactly("a", "b", "c", "d", "e", "f").inOrder(); SortedSet<String> subset = elementSet.subSet("b", "f"); ASSERT.that(subset).has().exactly("b", "c", "d", "e").inOrder(); assertTrue(subset.remove("c")); ASSERT.that(elementSet).has().exactly("a", "b", "d", "e", "f").inOrder(); ASSERT.that(subset).has().exactly("b", "d", "e").inOrder(); assertEquals(10, ms.size()); assertFalse(subset.remove("a")); ASSERT.that(elementSet).has().exactly("a", "b", "d", "e", "f").inOrder(); ASSERT.that(subset).has().exactly("b", "d", "e").inOrder(); assertEquals(10, ms.size()); }
@Override public int getNumberOfTimeouts() { return keepAliveTimeouts.size() + timeouts.size(); }