Search in sources :

Example 1 with MutableByteSet

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

the class AbstractMutableSet method collectByte.

@Override
public MutableByteSet collectByte(ByteFunction<? super T> byteFunction) {
    MutableByteSet result = new ByteHashSet();
    this.forEach(new CollectByteProcedure<>(byteFunction, result));
    return result;
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) ByteHashSet(org.eclipse.collections.impl.set.mutable.primitive.ByteHashSet)

Example 2 with MutableByteSet

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

the class ByteHashSet method reject.

@Override
public MutableByteSet reject(BytePredicate predicate) {
    MutableByteSet result = new ByteHashSet();
    this.forEach(value -> {
        if (!predicate.accept(value)) {
            result.add(value);
        }
    });
    return result;
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet)

Example 3 with MutableByteSet

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

the class ByteHashSet method chunk.

@Override
public RichIterable<ByteIterable> chunk(int size) {
    if (size <= 0) {
        throw new IllegalArgumentException("Size for groups must be positive but was: " + size);
    }
    MutableList<ByteIterable> result = Lists.mutable.empty();
    if (this.notEmpty()) {
        if (this.size() <= size) {
            result.add(ByteSets.mutable.withAll(this));
        } else {
            ByteIterator iterator = this.byteIterator();
            while (iterator.hasNext()) {
                MutableByteSet batch = ByteSets.mutable.empty();
                for (int i = 0; i < size && iterator.hasNext(); i++) {
                    batch.add(iterator.next());
                }
                result.add(batch);
            }
        }
    }
    return result;
}
Also used : MutableByteIterator(org.eclipse.collections.api.iterator.MutableByteIterator) ByteIterator(org.eclipse.collections.api.iterator.ByteIterator) LazyByteIterable(org.eclipse.collections.api.LazyByteIterable) ByteIterable(org.eclipse.collections.api.ByteIterable) MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet)

Example 4 with MutableByteSet

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

the class AbstractImmutableSet method collectByte.

@Override
public ImmutableByteSet collectByte(ByteFunction<? super T> byteFunction) {
    MutableByteSet result = new ByteHashSet();
    this.forEach(new CollectByteProcedure<>(byteFunction, result));
    return result.toImmutable();
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) ByteHashSet(org.eclipse.collections.impl.set.mutable.primitive.ByteHashSet)

Example 5 with MutableByteSet

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

the class AbstractByteSetTestCase method byteIterator_throws.

@Override
@Test(expected = NoSuchElementException.class)
public void byteIterator_throws() {
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) -1, (byte) -31);
    ByteIterator iterator = set.byteIterator();
    while (iterator.hasNext()) {
        iterator.next();
    }
    iterator.next();
}
Also used : ByteIterator(org.eclipse.collections.api.iterator.ByteIterator) MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Aggregations

MutableByteSet (org.eclipse.collections.api.set.primitive.MutableByteSet)25 Test (org.junit.Test)21 ByteIterator (org.eclipse.collections.api.iterator.ByteIterator)4 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)3 LazyByteIterable (org.eclipse.collections.api.LazyByteIterable)2 ByteHashSet (org.eclipse.collections.impl.set.mutable.primitive.ByteHashSet)2 NoSuchElementException (java.util.NoSuchElementException)1 ByteIterable (org.eclipse.collections.api.ByteIterable)1 MutableByteIterator (org.eclipse.collections.api.iterator.MutableByteIterator)1 MutableSet (org.eclipse.collections.api.set.MutableSet)1 ByteHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag)1 BytePredicates (org.eclipse.collections.impl.block.factory.primitive.BytePredicates)1 AbstractMutableByteCollectionTestCase (org.eclipse.collections.impl.collection.mutable.primitive.AbstractMutableByteCollectionTestCase)1 ByteSets (org.eclipse.collections.impl.factory.primitive.ByteSets)1 UnifiedSet (org.eclipse.collections.impl.set.mutable.UnifiedSet)1 Verify (org.eclipse.collections.impl.test.Verify)1 Assert (org.junit.Assert)1