BucketMessageGroups implements MessageGroups<C> { @Override public void put(SimpleString key, C consumer) { if (buckets == null) { buckets = newBucketArray(bucketCount); } if (buckets[getBucket(key)] == null) { size++; } buckets[getBucket(key)] = consumer; } BucketMessageGroups(int bucketCount); @Override void put(SimpleString key, C consumer); @Override C get(SimpleString key); @Override C remove(SimpleString key); @Override boolean removeIf(Predicate<? super C> filter); @Override void removeAll(); @Override int size(); @Override Map<SimpleString, C> toMap();  }
@Test public void testPut() { MessageGroups<String> messageGroups = new BucketMessageGroups<>(2); assertEquals(0, messageGroups.size()); messageGroups.put(toGroupBucketIntKey(1), "world"); assertEquals(1, messageGroups.size()); messageGroups.put(toGroupBucketIntKey(2), "world2"); assertEquals(2, messageGroups.size()); messageGroups.put(toGroupBucketIntKey(3), "world3"); assertEquals(2, messageGroups.size()); }