Search in sources :

Example 11 with ByteArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList in project eclipse-collections by eclipse.

the class ImmutableEmptySortedBagTest method collectByte_target.

@Override
@Test
public void collectByte_target() {
    ImmutableSortedBag<Integer> bag = this.classUnderTest();
    Assert.assertEquals(new ByteArrayList(), bag.collectByte(PrimitiveFunctions.unboxIntegerToByte(), new ByteArrayList()));
    ImmutableSortedBag<Integer> bag2 = this.classUnderTest();
    Assert.assertEquals(new ByteHashBag(), bag2.collectByte(PrimitiveFunctions.unboxIntegerToByte(), new ByteHashBag()));
}
Also used : ByteHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) Test(org.junit.Test)

Example 12 with ByteArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList in project eclipse-collections by eclipse.

the class ImmutableByteByteMapKeySetTest method generateCollisions.

protected static ByteArrayList generateCollisions() {
    ByteArrayList collisions = new ByteArrayList();
    ImmutableByteByteMapKeySet set = (ImmutableByteByteMapKeySet) new ByteByteHashMap().keySet().freeze();
    for (byte i = 2; collisions.size() <= 10; i++) {
        if (set.spreadAndMask(i) == set.spreadAndMask((byte) 2)) {
            collisions.add(i);
        }
    }
    return collisions;
}
Also used : ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)

Example 13 with ByteArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList in project narchy by automenta.

the class Subterms method equivalentStructures.

// TODO optionally allow atomic structure positions to differ
default boolean equivalentStructures() {
    int t0Struct = sub(0).structure();
    int s = subs();
    for (int i = 1; i < s; i++) {
        if (sub(i).structure() != t0Struct)
            return false;
    }
    ByteList structureKey = sub(0).structureKey();
    ByteArrayList reuseKey = new ByteArrayList(structureKey.size());
    for (int i = 1; i < s; i++) {
        // TODO only needs to construct the key while comparing equality with the first
        if (!sub(i).structureKey(reuseKey).equals(structureKey))
            return false;
        reuseKey.clear();
    }
    return true;
}
Also used : ByteList(org.eclipse.collections.api.list.primitive.ByteList) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)

Example 14 with ByteArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList in project eclipse-collections by eclipse.

the class AbstractImmutableSortedMap method collectByte.

@Override
public ImmutableByteList collectByte(ByteFunction<? super V> byteFunction) {
    ByteArrayList result = new ByteArrayList(this.size());
    this.forEach(new CollectByteProcedure<>(byteFunction, result));
    return result.toImmutable();
}
Also used : ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)

Example 15 with ByteArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList in project eclipse-collections by eclipse.

the class AbstractImmutableSortedSet method collectByte.

@Override
public ImmutableByteList collectByte(ByteFunction<? super T> byteFunction) {
    ByteArrayList result = new ByteArrayList(this.size());
    this.forEach(new CollectByteProcedure<>(byteFunction, result));
    return result.toImmutable();
}
Also used : ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)

Aggregations

ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)23 Test (org.junit.Test)11 MutableByteCollection (org.eclipse.collections.api.collection.primitive.MutableByteCollection)3 MutableByteList (org.eclipse.collections.api.list.primitive.MutableByteList)3 ArrayList (java.util.ArrayList)2 MutableByteSet (org.eclipse.collections.api.set.primitive.MutableByteSet)2 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)2 CharArrayList (org.eclipse.collections.impl.list.mutable.primitive.CharArrayList)2 DoubleArrayList (org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList)2 FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)2 IntArrayList (org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2 ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)2 BigInteger (java.math.BigInteger)1 ByteIterable (org.eclipse.collections.api.ByteIterable)1 ByteList (org.eclipse.collections.api.list.primitive.ByteList)1 ByteHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag)1