Search in sources :

Example 1 with MutableDoubleSet

use of org.eclipse.collections.api.set.primitive.MutableDoubleSet in project eclipse-collections by eclipse.

the class AbstractMutableSet method collectDouble.

@Override
public MutableDoubleSet collectDouble(DoubleFunction<? super T> doubleFunction) {
    MutableDoubleSet result = new DoubleHashSet(this.size());
    this.forEach(new CollectDoubleProcedure<>(doubleFunction, result));
    return result;
}
Also used : DoubleHashSet(org.eclipse.collections.impl.set.mutable.primitive.DoubleHashSet) MutableDoubleSet(org.eclipse.collections.api.set.primitive.MutableDoubleSet)

Example 2 with MutableDoubleSet

use of org.eclipse.collections.api.set.primitive.MutableDoubleSet in project eclipse-collections by eclipse.

the class AbstractImmutableSet method collectDouble.

@Override
public ImmutableDoubleSet collectDouble(DoubleFunction<? super T> doubleFunction) {
    MutableDoubleSet result = new DoubleHashSet(this.size());
    this.forEach(new CollectDoubleProcedure<>(doubleFunction, result));
    return result.toImmutable();
}
Also used : DoubleHashSet(org.eclipse.collections.impl.set.mutable.primitive.DoubleHashSet) MutableDoubleSet(org.eclipse.collections.api.set.primitive.MutableDoubleSet)

Example 3 with MutableDoubleSet

use of org.eclipse.collections.api.set.primitive.MutableDoubleSet in project eclipse-collections by eclipse.

the class PrimitiveStreamsTest method toDoubleSet.

@Test
public void toDoubleSet() {
    MutableDoubleSet set = PrimitiveStreams.mDoubleSet(DoubleStream.of(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0));
    Assert.assertEquals(DoubleSets.mutable.ofAll(IntInterval.oneTo(10).asLazy().collectDouble(i -> (double) i)), set);
    Assert.assertEquals(DoubleSets.immutable.ofAll(DoubleStream.of(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0)), set);
}
Also used : MutableDoubleSet(org.eclipse.collections.api.set.primitive.MutableDoubleSet) Test(org.junit.Test)

Aggregations

MutableDoubleSet (org.eclipse.collections.api.set.primitive.MutableDoubleSet)3 DoubleHashSet (org.eclipse.collections.impl.set.mutable.primitive.DoubleHashSet)2 Test (org.junit.Test)1