Search in sources :

Example 1 with HashBiMap

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();
}
Also used : Random(java.util.Random) HashBiMap(org.eclipse.collections.impl.bimap.mutable.HashBiMap)

Example 2 with HashBiMap

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();
}
Also used : Random(java.util.Random) HashBiMap(org.eclipse.collections.impl.bimap.mutable.HashBiMap)

Example 3 with HashBiMap

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();
}
Also used : Random(java.util.Random) HashBiMap(org.eclipse.collections.impl.bimap.mutable.HashBiMap)

Example 4 with HashBiMap

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();
}
Also used : Random(java.util.Random) HashBiMap(org.eclipse.collections.impl.bimap.mutable.HashBiMap)

Example 5 with HashBiMap

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;
}
Also used : Random(java.util.Random) HashBiMap(org.eclipse.collections.impl.bimap.mutable.HashBiMap)

Aggregations

Random (java.util.Random)5 HashBiMap (org.eclipse.collections.impl.bimap.mutable.HashBiMap)5