@Override public int sizeDistinct() { return this.map.size(); }
@Override public int sizeDistinct() { return this.map.size(); }
public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(this.map.size()); this.map.forEachKeyValue(new MultimapKeyValuesSerializingProcedure<>(out)); }
@Override public void writeExternal(ObjectOutput out) throws IOException { int keysCount = this.map.size(); out.writeInt(keysCount); this.map.forEachKeyValue(new CheckedProcedure2<K, MutableBag<V>>() { public void safeValue(K key, MutableBag<V> bag) throws IOException { out.writeObject(key); out.writeInt(bag.sizeDistinct()); bag.forEachWithOccurrences(new CheckedObjectIntProcedure<V>() { public void safeValue(V value, int count) throws IOException { out.writeObject(value); out.writeInt(count); } }); } }); }
@Override public void writeExternal(ObjectOutput out) throws IOException { int keysCount = this.map.size(); out.writeInt(keysCount); this.map.forEachKeyValue(new CheckedProcedure2<K, MutableBag<V>>() { public void safeValue(K key, MutableBag<V> bag) throws IOException { out.writeObject(key); out.writeInt(bag.sizeDistinct()); bag.forEachWithOccurrences(new CheckedObjectIntProcedure<V>() { public void safeValue(V value, int count) throws IOException { out.writeObject(value); out.writeInt(count); } }); } }); }
public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(this.map.size()); this.map.forEachKeyValue(new MultimapKeyValuesSerializingProcedure<>(out)); }
/** * @return mapping of user IDs to count of items the user has interacted with */ public Map<String,Integer> getUserCounts() { Map<String,Integer> counts; try (AutoLock al = knownItemsLock.autoReadLock()) { counts = new HashMap<>(knownItems.size()); knownItems.forEach((userID, ids) -> { int numItems; synchronized (ids) { numItems = ids.size(); } counts.put(userID, numItems); }); } return counts; }
@Override public <R extends Collection<V>> MutableMap<K, R> toMap(Function0<R> collectionFactory) { MutableMap<K, R> result = (MutableMap<K, R>) this.createMapWithKeyCount(this.map.size()); this.map.forEachKeyValue((key, collection) -> { R mutableCollection = collectionFactory.value(); mutableCollection.addAll(collection); result.put(key, mutableCollection); }); return result; }
@Override public <R extends Collection<V>> MutableMap<K, R> toMap(Function0<R> collectionFactory) { MutableMap<K, R> result = (MutableMap<K, R>) this.createMapWithKeyCount(this.map.size()); this.map.forEachKeyValue((key, collection) -> { R mutableCollection = collectionFactory.value(); mutableCollection.addAll(collection); result.put(key, mutableCollection); }); return result; }
@Override public ImmutableBagMultimap<K, V> toImmutable() { MutableMap<K, ImmutableBag<V>> result = (MutableMap<K, ImmutableBag<V>>) (MutableMap<?, ?>) this.createMapWithKeyCount(this.map.size()); this.map.forEachKeyValue((key, bag) -> result.put(key, bag.toImmutable())); return new ImmutableBagMultimapImpl<>(result); }
@Override public ImmutableBagMultimap<K, V> toImmutable() { MutableMap<K, ImmutableBag<V>> result = (MutableMap<K, ImmutableBag<V>>) (MutableMap<?, ?>) this.createMapWithKeyCount(this.map.size()); this.map.forEachKeyValue((key, bag) -> result.put(key, bag.toImmutable())); return new ImmutableBagMultimapImpl<>(result); }
@Override public int sizeDistinct() { return this.map.size(); }
@Override public void writeExternal(ObjectOutput out) throws IOException { int keysCount = this.map.size(); out.writeInt(keysCount); this.map.forEachKeyValue(new CheckedProcedure2<K, MutableBag<V>>() { public void safeValue(K key, MutableBag<V> bag) throws IOException { out.writeObject(key); out.writeInt(bag.sizeDistinct()); bag.forEachWithOccurrences(new CheckedObjectIntProcedure<V>() { public void safeValue(V value, int count) throws IOException { out.writeObject(value); out.writeInt(count); } }); } }); }
public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(this.map.size()); this.map.forEachKeyValue(new MultimapKeyValuesSerializingProcedure<>(out)); }
@Override public <R extends Collection<V>> MutableMap<K, R> toMap(Function0<R> collectionFactory) { MutableMap<K, R> result = (MutableMap<K, R>) this.createMapWithKeyCount(this.map.size()); this.map.forEachKeyValue((key, collection) -> { R mutableCollection = collectionFactory.value(); mutableCollection.addAll(collection); result.put(key, mutableCollection); }); return result; }
@Override public ImmutableBagMultimap<K, V> toImmutable() { MutableMap<K, ImmutableBag<V>> result = (MutableMap<K, ImmutableBag<V>>) (MutableMap<?, ?>) this.createMapWithKeyCount(this.map.size()); this.map.forEachKeyValue((key, bag) -> result.put(key, bag.toImmutable())); return new ImmutableBagMultimapImpl<>(result); }