Search in sources :

Example 26 with Interval

use of org.eclipse.collections.impl.list.Interval in project eclipse-collections by eclipse.

the class ParallelIterateAcceptanceTest method setUp.

@Before
public void setUp() {
    Interval interval = Interval.oneTo(20000);
    this.iterables = Lists.immutable.of(interval.toList(), interval.toList().asUnmodifiable(), interval.toList().asSynchronized(), interval.toList().toImmutable(), interval.toSet(), interval.toSet().asUnmodifiable(), interval.toSet().asSynchronized(), interval.toSet().toImmutable(), interval.toBag(), interval.toBag().asUnmodifiable(), interval.toBag().asSynchronized(), interval.toBag().toImmutable(), interval.toSortedSet(), interval.toSortedSet().asUnmodifiable(), interval.toSortedSet().asSynchronized(), interval.toSortedSet().toImmutable(), interval.toMap(Functions.getPassThru(), Functions.getPassThru()), interval.toMap(Functions.getPassThru(), Functions.getPassThru()).asUnmodifiable(), interval.toMap(Functions.getPassThru(), Functions.getPassThru()).asSynchronized(), interval.toMap(Functions.getPassThru(), Functions.getPassThru()).toImmutable(), ArrayListAdapter.<Integer>newList().withAll(interval), ArrayListAdapter.<Integer>newList().withAll(interval).asUnmodifiable(), ArrayListAdapter.<Integer>newList().withAll(interval).asSynchronized(), new CompositeFastList<Integer>().withAll(interval.toList()), new CompositeFastList<Integer>().withAll(interval.toList()).asUnmodifiable(), new CompositeFastList<Integer>().withAll(interval.toList()).asSynchronized(), new CompositeFastList<Integer>().withAll(interval.toList()).toImmutable(), ListAdapter.adapt(new LinkedList<Integer>()).withAll(interval), ListAdapter.adapt(new LinkedList<Integer>()).withAll(interval).asUnmodifiable(), ListAdapter.adapt(new LinkedList<Integer>()).withAll(interval).asSynchronized(), UnifiedSetWithHashingStrategy.<Integer>newSet(HashingStrategies.defaultStrategy()).withAll(interval), UnifiedSetWithHashingStrategy.<Integer>newSet(HashingStrategies.defaultStrategy()).withAll(interval).asUnmodifiable(), UnifiedSetWithHashingStrategy.<Integer>newSet(HashingStrategies.defaultStrategy()).withAll(interval).asSynchronized(), UnifiedSetWithHashingStrategy.<Integer>newSet(HashingStrategies.defaultStrategy()).withAll(interval).toImmutable());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CompositeFastList(org.eclipse.collections.impl.list.mutable.CompositeFastList) LinkedList(java.util.LinkedList) Interval(org.eclipse.collections.impl.list.Interval) Before(org.junit.Before)

Example 27 with Interval

use of org.eclipse.collections.impl.list.Interval in project eclipse-collections by eclipse.

the class ImmutableArrayStack method zipWithIndex.

@Override
public ImmutableStack<Pair<T, Integer>> zipWithIndex() {
    int maxIndex = this.delegate.size() - 1;
    Interval indices = Interval.fromTo(0, maxIndex);
    return ImmutableArrayStack.newStackFromTopToBottom(this.delegate.asReversed().zip(indices).toList());
}
Also used : Interval(org.eclipse.collections.impl.list.Interval)

Example 28 with Interval

use of org.eclipse.collections.impl.list.Interval in project eclipse-collections by eclipse.

the class ImmutableTreeMapTest method entrySet.

@Override
public void entrySet() {
    super.entrySet();
    Interval interval = Interval.oneTo(100);
    LazyIterable<Pair<String, Integer>> pairs = interval.collect(Object::toString).zip(interval);
    MutableSortedMap<String, Integer> mutableSortedMap = new TreeSortedMap<>(pairs.toArray(new Pair[] {}));
    ImmutableSortedMap<String, Integer> immutableSortedMap = mutableSortedMap.toImmutable();
    MutableList<Map.Entry<String, Integer>> entries = FastList.newList(immutableSortedMap.castToSortedMap().entrySet());
    MutableList<Map.Entry<String, Integer>> sortedEntries = entries.toSortedListBy(Map.Entry::getKey);
    Assert.assertEquals(sortedEntries, entries);
}
Also used : TreeSortedMap(org.eclipse.collections.impl.map.sorted.mutable.TreeSortedMap) Interval(org.eclipse.collections.impl.list.Interval) Pair(org.eclipse.collections.api.tuple.Pair)

Example 29 with Interval

use of org.eclipse.collections.impl.list.Interval in project eclipse-collections by eclipse.

the class SerialParallelLazyPerformanceTest method getIntegerListGenerators.

private MutableList<Function0<FastList<Integer>>> getIntegerListGenerators(int count, boolean shuffle) {
    Interval interval = Interval.fromTo(-(count / 2), count / 2 - 1);
    MutableList<Function0<FastList<Integer>>> generators = FastList.newList();
    generators.add(() -> {
        FastList<Integer> integers = FastList.newList(interval);
        if (shuffle) {
            integers.shuffleThis();
        }
        return integers;
    });
    return generators.shuffleThis();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Function0(org.eclipse.collections.api.block.function.Function0) Interval(org.eclipse.collections.impl.list.Interval) IntInterval(org.eclipse.collections.impl.list.primitive.IntInterval)

Example 30 with Interval

use of org.eclipse.collections.impl.list.Interval in project eclipse-collections by eclipse.

the class SerialParallelPerformanceTest method getIntegerListGenerators.

private MutableList<Function0<Iterable<Integer>>> getIntegerListGenerators(int count) {
    Interval interval = Interval.fromTo(-(count / 2), count / 2 - 1);
    MutableList<Function0<Iterable<Integer>>> generators = FastList.newList();
    generators.add(() -> interval.toList().shuffleThis());
    generators.add(() -> {
        MutableList<Integer> integers = interval.toList().shuffleThis();
        return integers.toImmutable();
    });
    generators.add(interval::toSet);
    return generators.shuffleThis();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Function0(org.eclipse.collections.api.block.function.Function0) Interval(org.eclipse.collections.impl.list.Interval) IntInterval(org.eclipse.collections.impl.list.primitive.IntInterval)

Aggregations

Interval (org.eclipse.collections.impl.list.Interval)32 Test (org.junit.Test)23 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 LinkedList (java.util.LinkedList)10 CompositeFastList (org.eclipse.collections.impl.list.mutable.CompositeFastList)10 Before (org.junit.Before)10 Function (org.eclipse.collections.api.block.function.Function)9 FastList (org.eclipse.collections.impl.list.mutable.FastList)9 Verify (org.eclipse.collections.impl.test.Verify)9 Assert (org.junit.Assert)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 MutableList (org.eclipse.collections.api.list.MutableList)8 MutableMap (org.eclipse.collections.api.map.MutableMap)8 BigInteger (java.math.BigInteger)7 Function2 (org.eclipse.collections.api.block.function.Function2)7 ImmutableList (org.eclipse.collections.api.list.ImmutableList)7 Predicates (org.eclipse.collections.impl.block.factory.Predicates)7 BigDecimal (java.math.BigDecimal)6 Arrays (java.util.Arrays)6