use of org.eclipse.collections.api.set.primitive.ImmutableByteSet in project eclipse-collections by eclipse.
the class AbstractImmutableByteHashSetTestCase method reject.
@Override
@Test
public void reject() {
super.reject();
ImmutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) 127, (byte) -1, (byte) -31, (byte) -64, (byte) -65, (byte) -128);
Verify.assertSize(6, set.reject(BytePredicates.greaterThan((byte) 0)));
Verify.assertSize(1, set.reject(BytePredicates.lessThan((byte) 32)));
}
use of org.eclipse.collections.api.set.primitive.ImmutableByteSet in project eclipse-collections by eclipse.
the class AbstractImmutableByteHashSetTestCase method testEquals.
@Override
@Test
public void testEquals() {
super.testEquals();
ImmutableByteSet set1 = this.newWith((byte) 1, (byte) 31, (byte) 32);
ImmutableByteSet set2 = this.newWith((byte) 32, (byte) 31, (byte) 1);
ImmutableByteSet set3 = this.newWith((byte) 32, (byte) 32, (byte) 31, (byte) 1);
ImmutableByteSet set4 = this.newWith((byte) 32, (byte) 32, (byte) 31, (byte) 1, (byte) 1);
Verify.assertEqualsAndHashCode(set1, set2);
Verify.assertEqualsAndHashCode(set1, set3);
Verify.assertEqualsAndHashCode(set1, set4);
Verify.assertEqualsAndHashCode(set2, set3);
Verify.assertEqualsAndHashCode(set2, set4);
}
use of org.eclipse.collections.api.set.primitive.ImmutableByteSet in project narchy by automenta.
the class CommonVariable method common.
public static Variable common(Variable A, Variable B) {
// 1. sort
if (A.compareTo(B) < 0) {
Variable c = B;
B = A;
A = c;
}
Op Aop = A.op();
assert (B.op() == Aop);
boolean aa = A instanceof NormalizedVariable;
boolean bb = B instanceof NormalizedVariable;
if (aa && bb) {
byte ai = ((NormalizedVariable) A).anonNum();
byte bi = ((NormalizedVariable) B).anonNum();
return new CommonVariable(Aop, ai, bi);
}
if (!aa && bb) {
ImmutableByteSet ai = ((CommonVariable) A).vars;
byte bi = ((NormalizedVariable) B).anonNum();
if (ai.contains(bi))
return A;
return new CommonVariable(Aop, ai.newWith(bi));
}
if (aa && !bb) {
byte ai = ((NormalizedVariable) A).anonNum();
ImmutableByteSet bi = ((CommonVariable) B).vars;
if (bi.contains(ai))
return B;
return new CommonVariable(Aop, bi.newWith(ai));
}
/*if (!aa && !bb)*/
{
ImmutableByteSet ai = ((CommonVariable) A).vars;
ImmutableByteSet bi = ((CommonVariable) B).vars;
ImmutableByteSet combined = ai.newWithAll(bi);
if (combined.equals(ai))
return A;
return new CommonVariable(Aop, combined);
}
}
use of org.eclipse.collections.api.set.primitive.ImmutableByteSet in project eclipse-collections by eclipse.
the class AbstractImmutableByteHashSetTestCase method select.
@Override
@Test
public void select() {
super.select();
ImmutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) 127, (byte) -1, (byte) -31, (byte) -64, (byte) -65, (byte) -128);
Verify.assertSize(8, set.select(BytePredicates.lessThan((byte) 32)));
Verify.assertSize(3, set.select(BytePredicates.greaterThan((byte) 0)));
}
use of org.eclipse.collections.api.set.primitive.ImmutableByteSet in project eclipse-collections by eclipse.
the class AbstractImmutableByteHashSetTestCase method byteIterator_throws.
@Override
@Test(expected = NoSuchElementException.class)
public void byteIterator_throws() {
ImmutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31);
ByteIterator iterator = set.byteIterator();
while (iterator.hasNext()) {
iterator.next();
}
iterator.next();
}
Aggregations