org.eclipse.collections.impl.map.immutable.primitive.ImmutableDoubleObjectSingletonMap Maven / Gradle / Ivy
Show all versions of eclipse-collections Show documentation
/*
* Copyright (c) 2022 Goldman Sachs and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*/
package org.eclipse.collections.impl.map.immutable.primitive;
import java.io.IOException;
import java.io.Serializable;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Optional;
import org.eclipse.collections.api.LazyDoubleIterable;
import org.eclipse.collections.api.LazyIterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.DoubleIterable;
import org.eclipse.collections.api.bag.ImmutableBag;
import org.eclipse.collections.api.bag.MutableBag;
import org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag;
import org.eclipse.collections.api.bag.primitive.ImmutableByteBag;
import org.eclipse.collections.api.bag.primitive.ImmutableCharBag;
import org.eclipse.collections.api.bag.primitive.ImmutableDoubleBag;
import org.eclipse.collections.api.bag.primitive.ImmutableFloatBag;
import org.eclipse.collections.api.bag.primitive.ImmutableIntBag;
import org.eclipse.collections.api.bag.primitive.ImmutableLongBag;
import org.eclipse.collections.api.bag.primitive.ImmutableShortBag;
import org.eclipse.collections.api.bag.sorted.MutableSortedBag;
import org.eclipse.collections.impl.bag.sorted.mutable.TreeBag;
import org.eclipse.collections.api.bimap.MutableBiMap;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.function.Function0;
import org.eclipse.collections.api.block.function.Function2;
import org.eclipse.collections.api.block.function.primitive.BooleanFunction;
import org.eclipse.collections.api.block.function.primitive.ByteFunction;
import org.eclipse.collections.api.block.function.primitive.CharFunction;
import org.eclipse.collections.api.block.function.primitive.DoubleFunction;
import org.eclipse.collections.api.block.function.primitive.DoubleObjectToDoubleFunction;
import org.eclipse.collections.api.block.function.primitive.FloatFunction;
import org.eclipse.collections.api.block.function.primitive.FloatObjectToFloatFunction;
import org.eclipse.collections.api.block.function.primitive.IntFunction;
import org.eclipse.collections.api.block.function.primitive.IntObjectToIntFunction;
import org.eclipse.collections.api.block.function.primitive.LongFunction;
import org.eclipse.collections.api.block.function.primitive.LongObjectToLongFunction;
import org.eclipse.collections.api.block.function.primitive.ShortFunction;
import org.eclipse.collections.api.block.predicate.Predicate;
import org.eclipse.collections.api.block.predicate.Predicate2;
import org.eclipse.collections.api.block.predicate.primitive.DoubleObjectPredicate;
import org.eclipse.collections.api.block.procedure.Procedure;
import org.eclipse.collections.api.block.procedure.Procedure2;
import org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure;
import org.eclipse.collections.api.block.procedure.primitive.DoubleObjectProcedure;
import org.eclipse.collections.api.block.procedure.primitive.DoubleProcedure;
import org.eclipse.collections.api.collection.primitive.MutableBooleanCollection;
import org.eclipse.collections.api.collection.primitive.MutableByteCollection;
import org.eclipse.collections.api.collection.primitive.MutableCharCollection;
import org.eclipse.collections.api.collection.primitive.MutableDoubleCollection;
import org.eclipse.collections.api.collection.primitive.MutableFloatCollection;
import org.eclipse.collections.api.collection.primitive.MutableIntCollection;
import org.eclipse.collections.api.collection.primitive.MutableLongCollection;
import org.eclipse.collections.api.collection.primitive.MutableShortCollection;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.map.ImmutableMap;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.map.MutableMapIterable;
import org.eclipse.collections.api.map.primitive.DoubleObjectMap;
import org.eclipse.collections.api.map.primitive.ImmutableDoubleObjectMap;
import org.eclipse.collections.api.map.primitive.ImmutableObjectDoubleMap;
import org.eclipse.collections.api.map.sorted.MutableSortedMap;
import org.eclipse.collections.api.multimap.MutableMultimap;
import org.eclipse.collections.api.multimap.bag.ImmutableBagMultimap;
import org.eclipse.collections.api.partition.bag.PartitionImmutableBag;
import org.eclipse.collections.api.partition.bag.PartitionMutableBag;
import org.eclipse.collections.api.set.ImmutableSet;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.api.set.primitive.MutableDoubleSet;
import org.eclipse.collections.api.set.sorted.MutableSortedSet;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.api.tuple.primitive.DoubleObjectPair;
import org.eclipse.collections.impl.UnmodifiableIteratorAdapter;
import org.eclipse.collections.impl.bag.mutable.HashBag;
import org.eclipse.collections.impl.block.procedure.PartitionProcedure;
import org.eclipse.collections.impl.block.procedure.PartitionPredicate2Procedure;
import org.eclipse.collections.impl.factory.Bags;
import org.eclipse.collections.impl.factory.BiMaps;
import org.eclipse.collections.impl.factory.Maps;
import org.eclipse.collections.impl.factory.Multimaps;
import org.eclipse.collections.impl.factory.Sets;
import org.eclipse.collections.impl.factory.SortedMaps;
import org.eclipse.collections.impl.factory.SortedSets;
import org.eclipse.collections.impl.factory.primitive.BooleanBags;
import org.eclipse.collections.impl.factory.primitive.ByteBags;
import org.eclipse.collections.impl.factory.primitive.CharBags;
import org.eclipse.collections.impl.factory.primitive.DoubleBags;
import org.eclipse.collections.impl.factory.primitive.FloatBags;
import org.eclipse.collections.impl.factory.primitive.IntBags;
import org.eclipse.collections.impl.factory.primitive.LongBags;
import org.eclipse.collections.impl.factory.primitive.ObjectDoubleMaps;
import org.eclipse.collections.impl.factory.primitive.ShortBags;
import org.eclipse.collections.impl.factory.primitive.DoubleLists;
import org.eclipse.collections.impl.lazy.LazyIterableAdapter;
import org.eclipse.collections.impl.map.mutable.primitive.DoubleObjectHashMap;
import org.eclipse.collections.impl.multimap.bag.HashBagMultimap;
import org.eclipse.collections.impl.partition.bag.PartitionHashBag;
import org.eclipse.collections.impl.set.mutable.UnifiedSet;
import org.eclipse.collections.impl.set.mutable.primitive.DoubleHashSet;
import org.eclipse.collections.impl.set.mutable.primitive.UnmodifiableDoubleSet;
import org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples;
import org.eclipse.collections.impl.utility.Iterate;
import org.eclipse.collections.impl.utility.internal.IterableIterate;
/**
* ImmutableDoubleObjectSingletonMap is an optimization for {@link ImmutableDoubleObjectMap} of size 1.
* This file was automatically generated from template file immutablePrimitiveObjectSingletonMap.stg.
*
* @since 4.0.
*/
final class ImmutableDoubleObjectSingletonMap extends AbstractImmutableDoubleObjectMap implements Serializable
{
private static final long serialVersionUID = 1L;
private final double key1;
private final V value1;
ImmutableDoubleObjectSingletonMap(double key1, V value1)
{
this.key1 = key1;
this.value1 = value1;
}
@Override
public V get(double key)
{
return Double.compare(this.key1, key) == 0 ? this.value1 : null;
}
@Override
public V getIfAbsent(double key, Function0 extends V> ifAbsent)
{
return Double.compare(this.key1, key) == 0 ? this.value1 : ifAbsent.value();
}
@Override
public boolean containsKey(double key)
{
return Double.compare(this.key1, key) == 0;
}
@Override
public boolean containsValue(Object value)
{
return nullSafeEquals(this.value1, value);
}
private static boolean nullSafeEquals(Object value, Object other)
{
if (value == null)
{
if (other == null)
{
return true;
}
}
else if (other == value || value.equals(other))
{
return true;
}
return false;
}
@Override
public ImmutableDoubleObjectMap tap(Procedure super V> procedure)
{
procedure.value(this.value1);
return this;
}
@Override
public void forEachValue(Procedure super V> procedure)
{
procedure.value(this.value1);
}
@Override
public void forEachKey(DoubleProcedure procedure)
{
procedure.value(this.key1);
}
@Override
public void forEachKeyValue(DoubleObjectProcedure super V> procedure)
{
procedure.value(this.key1, this.value1);
}
@Override
public ImmutableDoubleObjectMap select(DoubleObjectPredicate super V> predicate)
{
return predicate.accept(this.key1, this.value1) ? DoubleObjectHashMap.newWithKeysValues(this.key1, this.value1).toImmutable()
: (ImmutableDoubleObjectMap) ImmutableDoubleObjectEmptyMap.INSTANCE;
}
@Override
public ImmutableDoubleObjectMap reject(DoubleObjectPredicate super V> predicate)
{
return predicate.accept(this.key1, this.value1) ? (ImmutableDoubleObjectMap) ImmutableDoubleObjectEmptyMap.INSTANCE
: DoubleObjectHashMap.newWithKeysValues(this.key1, this.value1).toImmutable();
}
@Override
public ImmutableDoubleObjectMap toImmutable()
{
return this;
}
@Override
public int size()
{
return 1;
}
@Override
public MutableDoubleSet keySet()
{
return UnmodifiableDoubleSet.of(DoubleHashSet.newSetWith(this.key1));
}
@Override
public Collection values()
{
return Lists.immutable.of(this.value1).castToList();
}
@Override
public LazyDoubleIterable keysView()
{
return DoubleLists.immutable.of(this.key1).asLazy();
}
@Override
public RichIterable> keyValuesView()
{
return Lists.immutable.of(PrimitiveTuples.pair(this.key1, this.value1)).asLazy();
}
@Override
public ImmutableObjectDoubleMap flipUniqueValues()
{
return ObjectDoubleMaps.immutable.with(this.value1, this.key1);
}
@Override
public boolean equals(Object obj)
{
if (obj == this)
{
return true;
}
if (!(obj instanceof DoubleObjectMap))
{
return false;
}
DoubleObjectMap map = (DoubleObjectMap) obj;
if (map.size() != 1)
{
return false;
}
return map.containsKey(this.key1) && nullSafeEquals(this.value1, map.get(this.key1));
}
@Override
public int hashCode()
{
return (int) (Double.doubleToLongBits(this.key1) ^ Double.doubleToLongBits(this.key1) >>> 32) ^ (this.value1 == null ? 0 : this.value1.hashCode());
}
@Override
public String toString()
{
return "{" + this.key1 + "=" + this.value1 + "}";
}
@Override
public boolean isEmpty()
{
return false;
}
@Override
public boolean notEmpty()
{
return true;
}
@Override
public V getFirst()
{
return this.value1;
}
@Override
public V getLast()
{
return this.value1;
}
@Override
public V getOnly()
{
return this.value1;
}
@Override
public boolean contains(Object object)
{
return this.containsValue(object);
}
@Override
public boolean containsAllIterable(Iterable> source)
{
for (Iterator> iterator = source.iterator(); iterator.hasNext(); )
{
if (!nullSafeEquals(this.value1, iterator.next()))
{
return false;
}
}
return true;
}
@Override
public boolean containsAll(Collection> source)
{
return this.containsAllIterable(source);
}
@Override
public boolean containsAllArguments(Object... elements)
{
for (Object item : elements)
{
if (!this.contains(item))
{
return false;
}
}
return true;
}
@Override
public ImmutableBag select(Predicate super V> predicate)
{
return predicate.accept(this.value1) ? Bags.immutable.with(this.value1) : Bags.immutable.with();
}
@Override
public > R select(Predicate super V> predicate, R target)
{
if (predicate.accept(this.value1))
{
target.add(this.value1);
}
return target;
}
@Override
public ImmutableBag selectWith(Predicate2 super V, ? super P> predicate, P parameter)
{
return predicate.accept(this.value1, parameter) ? Bags.immutable.with(this.value1) : Bags.immutable.with();
}
@Override
public > R selectWith(Predicate2 super V, ? super P> predicate, P parameter, R targetCollection)
{
if (predicate.accept(this.value1, parameter))
{
targetCollection.add(this.value1);
}
return targetCollection;
}
@Override
public ImmutableBag reject(Predicate super V> predicate)
{
return predicate.accept(this.value1) ? Bags.immutable.with() : Bags.immutable.with(this.value1);
}
@Override
public > R reject(Predicate super V> predicate, R target)
{
if (!predicate.accept(this.value1))
{
target.add(this.value1);
}
return target;
}
@Override
public ImmutableBag rejectWith(Predicate2 super V, ? super P> predicate, P parameter)
{
return predicate.accept(this.value1, parameter) ? Bags.immutable.with() : Bags.immutable.with(this.value1);
}
@Override
public > R rejectWith(Predicate2 super V, ? super P> predicate, P parameter, R targetCollection)
{
if (!predicate.accept(this.value1, parameter))
{
targetCollection.add(this.value1);
}
return targetCollection;
}
@Override
public PartitionImmutableBag partition(Predicate super V> predicate)
{
PartitionMutableBag partitionMutableBag = new PartitionHashBag<>();
this.forEach(new PartitionProcedure(predicate, partitionMutableBag));
return partitionMutableBag.toImmutable();
}
@Override
public PartitionImmutableBag partitionWith(Predicate2 super V, ? super P> predicate, P parameter)
{
PartitionMutableBag partitionMutableBag = new PartitionHashBag<>();
this.forEach(new PartitionPredicate2Procedure(predicate, parameter, partitionMutableBag));
return partitionMutableBag.toImmutable();
}
@Override
public ImmutableBag selectInstancesOf(Class clazz)
{
return clazz.isInstance(this.value1) ? Bags.immutable.with(clazz.cast(this.value1)) : Bags.immutable.with();
}
@Override
public ImmutableBag collect(Function super V, ? extends VV> function)
{
return Bags.immutable.with(function.valueOf(this.value1));
}
@Override
public ImmutableBooleanBag collectBoolean(BooleanFunction super V> booleanFunction)
{
return BooleanBags.immutable.with(booleanFunction.booleanValueOf(this.value1));
}
@Override
public R collectBoolean(BooleanFunction super V> booleanFunction, R target)
{
target.add(booleanFunction.booleanValueOf(this.value1));
return target;
}
@Override
public ImmutableByteBag collectByte(ByteFunction super V> byteFunction)
{
return ByteBags.immutable.with(byteFunction.byteValueOf(this.value1));
}
@Override
public R collectByte(ByteFunction super V> byteFunction, R target)
{
target.add(byteFunction.byteValueOf(this.value1));
return target;
}
@Override
public ImmutableCharBag collectChar(CharFunction super V> charFunction)
{
return CharBags.immutable.with(charFunction.charValueOf(this.value1));
}
@Override
public R collectChar(CharFunction super V> charFunction, R target)
{
target.add(charFunction.charValueOf(this.value1));
return target;
}
@Override
public ImmutableDoubleBag collectDouble(DoubleFunction super V> doubleFunction)
{
return DoubleBags.immutable.with(doubleFunction.doubleValueOf(this.value1));
}
@Override
public R collectDouble(DoubleFunction super V> doubleFunction, R target)
{
target.add(doubleFunction.doubleValueOf(this.value1));
return target;
}
@Override
public ImmutableFloatBag collectFloat(FloatFunction super V> floatFunction)
{
return FloatBags.immutable.with(floatFunction.floatValueOf(this.value1));
}
@Override
public R collectFloat(FloatFunction super V> floatFunction, R target)
{
target.add(floatFunction.floatValueOf(this.value1));
return target;
}
@Override
public ImmutableIntBag collectInt(IntFunction super V> intFunction)
{
return IntBags.immutable.with(intFunction.intValueOf(this.value1));
}
@Override
public R collectInt(IntFunction super V> intFunction, R target)
{
target.add(intFunction.intValueOf(this.value1));
return target;
}
@Override
public ImmutableLongBag collectLong(LongFunction super V> longFunction)
{
return LongBags.immutable.with(longFunction.longValueOf(this.value1));
}
@Override
public R collectLong(LongFunction super V> longFunction, R target)
{
target.add(longFunction.longValueOf(this.value1));
return target;
}
@Override
public ImmutableShortBag collectShort(ShortFunction super V> shortFunction)
{
return ShortBags.immutable.with(shortFunction.shortValueOf(this.value1));
}
@Override
public R collectShort(ShortFunction super V> shortFunction, R target)
{
target.add(shortFunction.shortValueOf(this.value1));
return target;
}
@Override
public ImmutableBag collectIf(Predicate super V> predicate, Function super V, ? extends VV> function)
{
return predicate.accept(this.value1) ? Bags.immutable.with(function.valueOf(this.value1)) : Bags.immutable.with();
}
@Override
public ImmutableBag flatCollect(Function super V, ? extends Iterable> function)
{
return Bags.immutable.withAll(function.valueOf(this.value1));
}
@Override
public V detect(Predicate super V> predicate)
{
return predicate.accept(this.value1) ? this.value1 : null;
}
@Override
public V detectWith(Predicate2 super V, ? super P> predicate, P parameter)
{
return predicate.accept(this.value1, parameter) ? this.value1 : null;
}
@Override
public Optional detectOptional(Predicate super V> predicate)
{
return predicate.accept(this.value1) ? Optional.of(this.value1) : Optional.empty();
}
@Override
public Optional detectWithOptional(Predicate2 super V, ? super P> predicate, P parameter)
{
return predicate.accept(this.value1, parameter) ? Optional.of(this.value1) : Optional.empty();
}
@Override
public V detectIfNone(Predicate super V> predicate, Function0 extends V> function)
{
return predicate.accept(this.value1) ? this.value1 : function.value();
}
@Override
public V detectWithIfNone(Predicate2 super V, ? super P> predicate, P parameter, Function0 extends V> function)
{
return predicate.accept(this.value1, parameter) ? this.value1 : function.value();
}
@Override
public int count(Predicate super V> predicate)
{
return predicate.accept(this.value1) ? 1 : 0;
}
@Override
public
int countWith(Predicate2 super V, ? super P> predicate, P parameter)
{
return predicate.accept(this.value1, parameter) ? 1 : 0;
}
@Override
public boolean anySatisfy(Predicate super V> predicate)
{
return predicate.accept(this.value1);
}
@Override
public
boolean anySatisfyWith(Predicate2 super V, ? super P> predicate, P parameter)
{
return predicate.accept(this.value1, parameter);
}
@Override
public boolean allSatisfy(Predicate super V> predicate)
{
return predicate.accept(this.value1);
}
@Override
public
boolean allSatisfyWith(Predicate2 super V, ? super P> predicate, P parameter)
{
return predicate.accept(this.value1, parameter);
}
@Override
public boolean noneSatisfy(Predicate super V> predicate)
{
return !predicate.accept(this.value1);
}
@Override
public
boolean noneSatisfyWith(Predicate2 super V, ? super P> predicate, P parameter)
{
return !predicate.accept(this.value1, parameter);
}
@Override
public IV injectInto(IV injectedValue, Function2 super IV, ? super V, ? extends IV> function)
{
return function.value(injectedValue, this.value1);
}
@Override
public int injectInto(int injectedValue, IntObjectToIntFunction super V> function)
{
return function.intValueOf(injectedValue, this.value1);
}
@Override
public long injectInto(long injectedValue, LongObjectToLongFunction super V> function)
{
return function.longValueOf(injectedValue, this.value1);
}
@Override
public float injectInto(float injectedValue, FloatObjectToFloatFunction super V> function)
{
return function.floatValueOf(injectedValue, this.value1);
}
@Override
public double injectInto(double injectedValue, DoubleObjectToDoubleFunction super V> function)
{
return function.doubleValueOf(injectedValue, this.value1);
}
@Override
public > R into(R target)
{
return Iterate.addAllTo(this, target);
}
@Override
public MutableList toList()
{
return Lists.mutable.with(this.value1);
}
@Override
public MutableList toSortedList()
{
return Lists.mutable.with(this.value1);
}
@Override
public MutableList toSortedList(Comparator super V> comparator)
{
return Lists.mutable.with(this.value1);
}
@Override
public MutableSet toSet()
{
return Sets.mutable.with(this.value1);
}
@Override
public MutableSortedSet toSortedSet()
{
return SortedSets.mutable.with(this.value1);
}
@Override
public MutableSortedSet toSortedSet(Comparator super V> comparator)
{
return SortedSets.mutable.with(this.value1);
}
@Override
public MutableBag toBag()
{
return Bags.mutable.with(this.value1);
}
@Override
public MutableSortedBag toSortedBag()
{
return TreeBag.newBagWith(this.value1);
}
@Override
public MutableSortedBag toSortedBag(Comparator super V> comparator)
{
return TreeBag.newBagWith(comparator, this.value1);
}
@Override
public MutableMap toMap(Function super V, ? extends NK> keyFunction, Function super V, ? extends NV> valueFunction)
{
return Maps.mutable.with(keyFunction.valueOf(this.value1), valueFunction.valueOf(this.value1));
}
@Override
public MutableSortedMap toSortedMap(Function super V, ? extends NK> keyFunction, Function super V, ? extends NV> valueFunction)
{
return SortedMaps.mutable.with(keyFunction.valueOf(this.value1), valueFunction.valueOf(this.value1));
}
@Override
public MutableSortedMap toSortedMap(Comparator super NK> comparator, Function super V, ? extends NK> keyFunction, Function super V, ? extends NV> valueFunction)
{
return SortedMaps.mutable.with(keyFunction.valueOf(this.value1), valueFunction.valueOf(this.value1));
}
@Override
public , NK, NV> MutableSortedMap toSortedMapBy(Function super NK, KK> sortBy, Function super V, ? extends NK> keyFunction, Function super V, ? extends NV> valueFunction)
{
return SortedMaps.mutable.with(keyFunction.valueOf(this.value1), valueFunction.valueOf(this.value1));
}
@Override
public MutableBiMap toBiMap(Function super V, ? extends NK> keyFunction, Function super V, ? extends NV> valueFunction)
{
return BiMaps.mutable.with(keyFunction.valueOf(this.value1), valueFunction.valueOf(this.value1));
}
@Override
public LazyIterable asLazy()
{
return new LazyIterableAdapter<>(Lists.mutable.with(this.value1));
}
@Override
public Object[] toArray()
{
return new Object[]{this.value1};
}
@Override
public T[] toArray(T[] a)
{
return (T[]) new Object[]{this.value1};
}
@Override
public V min(Comparator super V> comparator)
{
return this.value1;
}
@Override
public V max(Comparator super V> comparator)
{
return this.value1;
}
@Override
public V min()
{
return this.value1;
}
@Override
public V max()
{
return this.value1;
}
@Override
public long sumOfInt(IntFunction super V> function)
{
return function.intValueOf(this.value1);
}
@Override
public double sumOfFloat(FloatFunction super V> function)
{
return function.floatValueOf(this.value1);
}
@Override
public long sumOfLong(LongFunction super V> function)
{
return function.longValueOf(this.value1);
}
@Override
public double sumOfDouble(DoubleFunction super V> function)
{
return function.doubleValueOf(this.value1);
}
@Override
public String makeString()
{
return this.makeString(", ");
}
@Override
public String makeString(String separator)
{
return this.makeString("", separator, "");
}
@Override
public String makeString(String start, String separator, String end)
{
Appendable stringBuilder = new StringBuilder();
this.appendString(stringBuilder, start, separator, end);
return stringBuilder.toString();
}
@Override
public void appendString(Appendable appendable)
{
this.appendString(appendable, ", ");
}
@Override
public void appendString(Appendable appendable, String separator)
{
this.appendString(appendable, "", separator, "");
}
@Override
public void appendString(Appendable appendable, String start, String separator, String end)
{
try
{
appendable.append(start);
appendable.append(String.valueOf(this.value1));
appendable.append(end);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
@Override
public ImmutableBagMultimap groupBy(Function super V, ? extends VV> function)
{
return Multimaps.immutable.bag.with(function.valueOf(this.value1), this.value1);
}
@Override
public > R groupBy(Function super V, ? extends VV> function, R target)
{
target.put(function.valueOf(this.value1), this.value1);
return target;
}
@Override
public ImmutableBagMultimap groupByEach(Function super V, ? extends Iterable> function)
{
return this.groupByEach(function, HashBagMultimap.newMultimap()).toImmutable();
}
@Override
public > R groupByEach(Function super V, ? extends Iterable> function, R target)
{
Iterable iterable = function.valueOf(this.value1);
for (VV key : iterable)
{
target.put(key, this.value1);
}
return target;
}
@Override
public ImmutableMap groupByUniqueKey(Function super V, ? extends VV> function)
{
return Maps.immutable.with(function.valueOf(this.value1), this.value1);
}
@Override
public > R groupByUniqueKey(Function super V, ? extends VV> function, R target)
{
if (target.put(function.valueOf(this.value1), this.value1) != null)
{
throw new IllegalStateException("Key " + function.valueOf(this.value1) + " already exists in map!");
}
return target;
}
@Override
public ImmutableBag> zip(Iterable that)
{
return this.zip(that, HashBag.>newBag()).toImmutable();
}
@Override
public >> R zip(Iterable that, R target)
{
return IterableIterate.zip(this, that, target);
}
@Override
public ImmutableSet> zipWithIndex()
{
return this.zipWithIndex(UnifiedSet.>newSet()).toImmutable();
}
@Override
public >> R zipWithIndex(R target)
{
return IterableIterate.zipWithIndex(this, target);
}
@Override
public RichIterable> chunk(int size)
{
if (size <= 0)
{
throw new IllegalArgumentException("Size for groups must be positive but was: " + size);
}
MutableList> result = Lists.mutable.of();
result.add(Lists.mutable.with(this.value1));
return result;
}
@Override
public > V maxBy(Function super V, ? extends VV> function)
{
return this.value1;
}
@Override
public > V minBy(Function super V, ? extends VV> function)
{
return this.value1;
}
@Override
public > MutableSortedSet toSortedSetBy(Function super V, ? extends VV> function)
{
return SortedSets.mutable.with(this.value1);
}
@Override
public > MutableList toSortedListBy(Function super V, ? extends VV> function)
{
return Lists.mutable.of(this.value1);
}
@Override
public > R flatCollect(Function super V, ? extends Iterable> function, R target)
{
Iterate.addAllTo(function.valueOf(this.value1), target);
return target;
}
@Override
public > R collectIf(Predicate super V> predicate, Function super V, ? extends VV> function, R target)
{
if (predicate.accept(this.value1))
{
target.add(function.valueOf(this.value1));
}
return target;
}
@Override
public ImmutableBag collectWith(Function2 super V, ? super P, ? extends VV> function, P parameter)
{
return Bags.immutable.with(function.value(this.value1, parameter));
}
@Override
public > R collectWith(Function2 super V, ? super P, ? extends VV> function, P parameter, R targetCollection)
{
targetCollection.add(function.value(this.value1, parameter));
return targetCollection;
}
@Override
public > R collect(Function super V, ? extends VV> function, R target)
{
target.add(function.valueOf(this.value1));
return target;
}
@Override
public ImmutableDoubleObjectMap newWithKeyValue(double key, V value)
{
return DoubleObjectHashMap.newWithKeysValues(this.key1, this.value1, key, value).toImmutable();
}
@Override
public ImmutableDoubleObjectMap newWithoutKey(double key)
{
return Double.compare(this.key1, key) == 0 ? (ImmutableDoubleObjectMap) ImmutableDoubleObjectEmptyMap.INSTANCE : this;
}
@Override
public ImmutableDoubleObjectMap newWithoutAllKeys(DoubleIterable keys)
{
return keys.contains(this.key1) ? (ImmutableDoubleObjectMap) ImmutableDoubleObjectEmptyMap.INSTANCE : this;
}
@Override
public void forEach(Procedure super V> procedure)
{
this.each(procedure);
}
@Override
public void each(Procedure super V> procedure)
{
procedure.value(this.value1);
}
@Override
public void forEachWithIndex(ObjectIntProcedure super V> objectIntProcedure)
{
objectIntProcedure.value(this.value1, 0);
}
@Override
public void forEachWith(Procedure2 super V, ? super P> procedure, P parameter)
{
procedure.value(this.value1, parameter);
}
@Override
public Iterator iterator()
{
return new UnmodifiableIteratorAdapter<>(DoubleObjectHashMap.newWithKeysValues(this.key1, this.value1).iterator());
}
private Object writeReplace()
{
return new ImmutableDoubleObjectMapSerializationProxy(this);
}
}