/** * @return true if the contents of two sets are equal */ public static <T> boolean equals(OrdinalSet<T> a, OrdinalSet<T> b) { if ((a == null && b == null) || a == b || (a.mapping == b.mapping && a.S == b.S)) { return true; } assert a != null && b != null; if (a.size() == b.size()) { if (a.mapping == b.mapping || (a.mapping != null && b.mapping != null && a.mapping.equals(b.mapping))) { return a.S == b.S || (a.S != null && b.S != null && a.S.sameValue(b.S)); } } return false; }
/** * @return true if the contents of two sets are equal */ public static <T> boolean equals(OrdinalSet<T> a, OrdinalSet<T> b) { if ((a == null && b == null) || a == b || (a.mapping == b.mapping && a.S == b.S)) { return true; } assert a != null && b != null; if (a.size() == b.size()) { if (a.mapping == b.mapping || (a.mapping != null && b.mapping != null && a.mapping.equals(b.mapping))) { return a.S == b.S || (a.S != null && b.S != null && a.S.sameValue(b.S)); } } return false; }
/** * @return true if the contents of two sets are equal */ public static <T> boolean equals(OrdinalSet<T> a, OrdinalSet<T> b) { if ((a == null && b == null) || a == b || (a.mapping == b.mapping && a.S == b.S)) { return true; } assert a != null && b != null; if (a.size() == b.size()) { if (a.mapping == b.mapping || (a.mapping != null && b.mapping != null && a.mapping.equals(b.mapping))) { return a.S == b.S || (a.S != null && b.S != null && a.S.sameValue(b.S)); } } return false; }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof SparseIntSet) { return sameValueInternal((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(this); } else if (that instanceof BitVectorIntSet) { return that.sameValue(this); } else if (that instanceof MutableSharedBitVectorIntSet) { return sameValue(((MutableSharedBitVectorIntSet) that).makeSparseCopy()); } else { Assertions.UNREACHABLE(that.getClass().toString()); return false; } }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof SparseIntSet) { return sameValueInternal((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(this); } else if (that instanceof BitVectorIntSet) { return that.sameValue(this); } else if (that instanceof MutableSharedBitVectorIntSet) { return sameValue(((MutableSharedBitVectorIntSet) that).makeSparseCopy()); } else { Assertions.UNREACHABLE(that.getClass().toString()); return false; } }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof SparseIntSet) { return sameValueInternal((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(this); } else if (that instanceof BitVectorIntSet) { return that.sameValue(this); } else if (that instanceof MutableSharedBitVectorIntSet) { return sameValue(((MutableSharedBitVectorIntSet) that).makeSparseCopy()); } else { Assertions.UNREACHABLE(that.getClass().toString()); return false; } }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof MutableSharedBitVectorIntSet) { return sameValue((MutableSharedBitVectorIntSet) that); } else if (that instanceof SparseIntSet) { return sameValue((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(makeSparseCopy()); } else if (that instanceof BitVectorIntSet) { return sameValue((BitVectorIntSet) that); } else if (that instanceof SemiSparseMutableIntSet) { return that.sameValue(this); } else { Assertions.UNREACHABLE("unexpected class " + that.getClass()); return false; } }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof MutableSharedBitVectorIntSet) { return sameValue((MutableSharedBitVectorIntSet) that); } else if (that instanceof SparseIntSet) { return sameValue((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(makeSparseCopy()); } else if (that instanceof BitVectorIntSet) { return sameValue((BitVectorIntSet) that); } else if (that instanceof SemiSparseMutableIntSet) { return that.sameValue(this); } else { Assertions.UNREACHABLE("unexpected class " + that.getClass()); return false; } }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof MutableSharedBitVectorIntSet) { return sameValue((MutableSharedBitVectorIntSet) that); } else if (that instanceof SparseIntSet) { return sameValue((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(makeSparseCopy()); } else if (that instanceof BitVectorIntSet) { return sameValue((BitVectorIntSet) that); } else if (that instanceof SemiSparseMutableIntSet) { return that.sameValue(this); } else { Assertions.UNREACHABLE("unexpected class " + that.getClass()); return false; } }
/** * This implementation must not despoil the original value of "this" * * @return a new IntSet which is the intersection of this and that */ @Override public IntSet intersection(IntSet that) { if (that instanceof DebuggingMutableIntSet) { DebuggingMutableIntSet db = (DebuggingMutableIntSet) that; IntSet ppr = primaryImpl.intersection(db.primaryImpl); IntSet ssr = secondaryImpl.intersection(db.secondaryImpl); assert ppr.sameValue(ssr); return ppr; } else { Assertions.UNREACHABLE(); return null; } }
/** * This implementation must not despoil the original value of "this" * * @return a new IntSet which is the intersection of this and that */ @Override public IntSet intersection(IntSet that) { if (that instanceof DebuggingMutableIntSet) { DebuggingMutableIntSet db = (DebuggingMutableIntSet) that; IntSet ppr = primaryImpl.intersection(db.primaryImpl); IntSet ssr = secondaryImpl.intersection(db.secondaryImpl); assert ppr.sameValue(ssr); return ppr; } else { Assertions.UNREACHABLE(); return null; } }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof BitVectorIntSet) { BitVectorIntSet b = (BitVectorIntSet) that; return bitVector.sameBits(b.bitVector); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(this); } else if (that instanceof SparseIntSet) { return sameValueInternal((SparseIntSet) that); } else if (that instanceof MutableSharedBitVectorIntSet) { return sameValue(((MutableSharedBitVectorIntSet) that).makeDenseCopy()); } else { Assertions.UNREACHABLE("unexpected argument type " + that.getClass()); return false; } }
/** * This implementation must not despoil the original value of "this" * * @return a new IntSet which is the intersection of this and that */ @Override public IntSet intersection(IntSet that) { if (that instanceof DebuggingMutableIntSet) { DebuggingMutableIntSet db = (DebuggingMutableIntSet) that; IntSet ppr = primaryImpl.intersection(db.primaryImpl); IntSet ssr = secondaryImpl.intersection(db.secondaryImpl); assert ppr.sameValue(ssr); return ppr; } else { Assertions.UNREACHABLE(); return null; } }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof BitVectorIntSet) { BitVectorIntSet b = (BitVectorIntSet) that; return bitVector.sameBits(b.bitVector); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(this); } else if (that instanceof SparseIntSet) { return sameValueInternal((SparseIntSet) that); } else if (that instanceof MutableSharedBitVectorIntSet) { return sameValue(((MutableSharedBitVectorIntSet) that).makeDenseCopy()); } else { Assertions.UNREACHABLE("unexpected argument type " + that.getClass()); return false; } }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof BitVectorIntSet) { BitVectorIntSet b = (BitVectorIntSet) that; return bitVector.sameBits(b.bitVector); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(this); } else if (that instanceof SparseIntSet) { return sameValueInternal((SparseIntSet) that); } else if (that instanceof MutableSharedBitVectorIntSet) { return sameValue(((MutableSharedBitVectorIntSet) that).makeDenseCopy()); } else { Assertions.UNREACHABLE("unexpected argument type " + that.getClass()); return false; } }
if (lhs.getValue() != null && intersect.sameValue(lhs.getValue())) { return NOT_CHANGED; } else {
if (lhs.getValue() != null && intersect.sameValue(lhs.getValue())) { return NOT_CHANGED; } else {
if (lhs.getValue() != null && intersect.sameValue(lhs.getValue())) { return NOT_CHANGED; } else {
Assert.assertTrue(IntSetUtil.diff(x, x, factory).isEmpty()); Assert.assertTrue(IntSetUtil.diff(z, v, factory).isEmpty()); Assert.assertTrue(IntSetUtil.diff(v, z, factory).sameValue(SparseIntSet.singleton(17))); Assert.assertTrue(IntSetUtil.diff(z, v, factory).isEmpty()); Assert.assertTrue(z.isSubset(v)); Assert.assertTrue(i.sameValue(SparseIntSet.singleton(7))); a.add(100); Assert.assertTrue(a.sameValue(a)); Assert.assertFalse(f.contains(8)); Assert.assertFalse(f.contains(9)); Assert.assertFalse(f.sameValue(b)); Assert.assertTrue(f.isSubset(b)); f = IntSetUtil.diff(b, tmp, factory); System.err.println(f); Assert.assertFalse(f.sameValue(b)); Assert.assertTrue(f.isSubset(b)); Assert.assertFalse(f.contains(51)); f = IntSetUtil.diff(b, tmp, factory); System.err.println(f); Assert.assertFalse(f.sameValue(b)); Assert.assertTrue(f.isSubset(b)); Assert.assertFalse(f.contains(51)); Assert.assertTrue(i.sameValue(SparseIntSet.singleton(7))); a.add(100);