public KeyedObjectMapBuilder<T> add(T... items) { for (T item: items) { add(item); } return this; }
public KeyedObjectMapBuilder<T> addAll(Iterable<? extends T> items) { for (T item: items) { add(item); } return this; }
@Override public EntityCollectionBuilder add(Entity e, boolean replace) { Preconditions.checkState(store != null, "build() already called"); Preconditions.checkArgument(e.getType().equals(type)); if (!replace && store.containsKey(e.getId())) { return this; } store.add(e); hasher.putInt(e.hashCode()); for (EntityIndexBuilder ib: indexBuilders.values()) { ib.add(e); } return this; }
static KeyedObjectMap<String> createMap(String... strings) { return KeyedObjectMap.newBuilder(StringEx.INSTANCE) .add(strings) .build(); }
@Override public EntityIndex build() { Preconditions.checkState(entityLists != null, "build() already called"); // arrange compact storage of the index KeyedObjectMapBuilder<IdBox<ImmutableList<Entity>>> bld = KeyedObjectMap.newBuilder(); for (Long2ObjectMap.Entry<ImmutableList.Builder<Entity>> entry: entityLists.long2ObjectEntrySet()) { long value = entry.getLongKey(); bld.add(IdBox.create(value, entry.getValue().build())); entry.setValue(null); } entityLists = null; return new LongEntityIndex(bld.build()); } }
builder.add(new SlopeOneModel.ModelRow(e.getKey(), idx, deviations, counts));
public KeyedObjectMapBuilder<T> add(T... items) { for (T item: items) { add(item); } return this; }
public KeyedObjectMapBuilder<T> addAll(Iterable<? extends T> items) { for (T item: items) { add(item); } return this; }
@Override public EntityCollectionBuilder add(Entity e, boolean replace) { Preconditions.checkState(store != null, "build() already called"); Preconditions.checkArgument(e.getType().equals(type)); if (!replace && store.containsKey(e.getId())) { return this; } store.add(e); hasher.putInt(e.hashCode()); for (EntityIndexBuilder ib: indexBuilders.values()) { ib.add(e); } return this; }
@Override public EntityIndex build() { Preconditions.checkState(entityLists != null, "build() already called"); // arrange compact storage of the index KeyedObjectMapBuilder<IdBox<ImmutableList<Entity>>> bld = KeyedObjectMap.newBuilder(); for (Long2ObjectMap.Entry<ImmutableList.Builder<Entity>> entry: entityLists.long2ObjectEntrySet()) { long value = entry.getLongKey(); bld.add(IdBox.create(value, entry.getValue().build())); entry.setValue(null); } entityLists = null; return new LongEntityIndex(bld.build()); } }