use of org.eclipse.collections.impl.bimap.mutable.HashBiMap in project eclipse-collections by eclipse.
the class ImmutableHashBiMapInverseTest method newWith.
@Override
public <T> ImmutableBiMap<Object, T> newWith(T... elements) {
Random random = new Random(CURRENT_TIME_MILLIS);
MutableBiMap<T, Object> result = new HashBiMap<>();
for (T each : elements) {
if (result.put(each, random.nextDouble()) != null) {
throw new IllegalStateException();
}
}
return result.toImmutable().inverse();
}
use of org.eclipse.collections.impl.bimap.mutable.HashBiMap in project eclipse-collections by eclipse.
the class ImmutableHashBiMapTest method newWith.
@Override
public <T> ImmutableBiMap<Object, T> newWith(T... elements) {
Random random = new Random(CURRENT_TIME_MILLIS);
MutableBiMap<Object, T> result = new HashBiMap<>();
for (T each : elements) {
try {
result.put(random.nextDouble(), each);
} catch (IllegalArgumentException e) {
throw new IllegalStateException(e);
}
}
return result.toImmutable();
}
use of org.eclipse.collections.impl.bimap.mutable.HashBiMap in project eclipse-collections by eclipse.
the class UnmodifiableBiMapTest method newWith.
@Override
public <T> MutableBiMap<Object, T> newWith(T... elements) {
Random random = new Random(CURRENT_TIME_MILLIS);
MutableBiMap<Object, T> result = new HashBiMap<>();
for (T each : elements) {
try {
result.put(random.nextDouble(), each);
} catch (IllegalArgumentException e) {
throw new IllegalStateException(e);
}
}
return result.asUnmodifiable();
}
use of org.eclipse.collections.impl.bimap.mutable.HashBiMap in project eclipse-collections by eclipse.
the class HashBiMapInverseTest method newWith.
@Override
public <T> MutableBiMap<Object, T> newWith(T... elements) {
Random random = new Random(CURRENT_TIME_MILLIS);
MutableBiMap<T, Object> result = new HashBiMap<>();
for (T each : elements) {
if (result.put(each, random.nextDouble()) != null) {
throw new IllegalStateException();
}
}
return result.inverse();
}
use of org.eclipse.collections.impl.bimap.mutable.HashBiMap in project eclipse-collections by eclipse.
the class HashBiMapTest method newWith.
@Override
public <T> MutableBiMap<Object, T> newWith(T... elements) {
Random random = new Random(CURRENT_TIME_MILLIS);
MutableBiMap<Object, T> result = new HashBiMap<>();
for (T each : elements) {
try {
result.put(random.nextDouble(), each);
} catch (IllegalArgumentException e) {
throw new IllegalStateException(e);
}
}
return result;
}