Search in sources :

Example 11 with ShortArrayList

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

the class ImmutableEmptySortedBagTest method collectShort.

@Override
@Test
public void collectShort() {
    ImmutableSortedBag<Integer> bag = this.classUnderTest();
    Assert.assertEquals(new ShortArrayList(), bag.collectShort(PrimitiveFunctions.unboxIntegerToShort()));
}
Also used : ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) Test(org.junit.Test)

Example 12 with ShortArrayList

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

the class Autoencoder method max.

public short[] max(float thresh) {
    float[] y = this.y;
    ShortArrayList s = null;
    int outs = y.length;
    for (int i = 0; i < outs; i++) {
        float Y = y[i];
        if (Y >= thresh) {
            if (s == null)
                s = new ShortArrayList(3);
            s.add((short) i);
        }
    }
    return (s == null) ? null : s.toArray();
}
Also used : ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)

Example 13 with ShortArrayList

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

the class MyShortIntHashMap method filter.

public void filter(IntPredicate toKeep) {
    int ss = size();
    if (ss == 0)
        return;
    SentinelValues sv = this.sentinelValues;
    if (sv != null && sv.containsZeroKey) {
        if (!toKeep.accept(sv.zeroValue)) {
            removeKey((short) 0);
            // because it may have changed
            sv = this.sentinelValues;
        }
    }
    if (sv != null && sv.containsOneKey) {
        if (!toKeep.accept(sv.oneValue)) {
            removeKey((short) 1);
            // because it may have changed
            sv = this.sentinelValues;
        }
    }
    ShortArrayList tmp = new ShortArrayList(ss / 2);
    short[] keys = this.keys;
    int sizeBefore = keys.length;
    int[] values = this.values;
    for (int i = 0; i < sizeBefore; ++i) {
        short k = keys[i];
        if (isNonSentinel(k) && !toKeep.accept(values[i])) {
            tmp.add(k);
        }
    }
    int s = tmp.size();
    if (s > 0) {
        tmp.forEach(this::removeKey);
    }
}
Also used : ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) AbstractSentinelValues(org.eclipse.collections.impl.map.mutable.primitive.AbstractSentinelValues)

Example 14 with ShortArrayList

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

the class AbstractImmutableSortedMap method collectShort.

@Override
public ImmutableShortList collectShort(ShortFunction<? super V> shortFunction) {
    ShortArrayList result = new ShortArrayList(this.size());
    this.forEach(new CollectShortProcedure<>(shortFunction, result));
    return result.toImmutable();
}
Also used : ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)

Example 15 with ShortArrayList

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

the class AbstractMutableSortedMap method collectShort.

@Override
public MutableShortList collectShort(ShortFunction<? super V> shortFunction) {
    ShortArrayList result = new ShortArrayList(this.size());
    this.forEach(new CollectShortProcedure<>(shortFunction, result));
    return result;
}
Also used : ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)

Aggregations

ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)20 Test (org.junit.Test)9 MutableShortCollection (org.eclipse.collections.api.collection.primitive.MutableShortCollection)3 MutableShortList (org.eclipse.collections.api.list.primitive.MutableShortList)3 ArrayList (java.util.ArrayList)2 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)2 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)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 BigInteger (java.math.BigInteger)1 ShortIterable (org.eclipse.collections.api.ShortIterable)1 ShortHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag)1 AbstractSentinelValues (org.eclipse.collections.impl.map.mutable.primitive.AbstractSentinelValues)1