/** * Invoke an action on each element of the Set */ @Override public void foreach(IntSetAction action) { if (action == null) { throw new IllegalArgumentException("null action"); } sparsePart.foreach(action); if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { action.act(b); } } }
/** * Invoke an action on each element of the Set */ @Override public void foreach(IntSetAction action) { if (action == null) { throw new IllegalArgumentException("null action"); } sparsePart.foreach(action); if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { action.act(b); } } }
/** * Invoke an action on each element of the Set */ @Override public void foreach(IntSetAction action) { if (action == null) { throw new IllegalArgumentException("null action"); } sparsePart.foreach(action); if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { action.act(b); } } }
/** * Interset this with another set. */ @Override public void intersectWith(IntSet set) { sparsePart.intersectWith(set); if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { if (!set.contains(b)) { densePart.clear(b); } } } }
/** * Interset this with another set. */ @Override public void intersectWith(IntSet set) { sparsePart.intersectWith(set); if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { if (!set.contains(b)) { densePart.clear(b); } } } }
/** * Interset this with another set. */ @Override public void intersectWith(IntSet set) { sparsePart.intersectWith(set); if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { if (!set.contains(b)) { densePart.clear(b); } } } }
/** * Invoke an action on each element of the Set, excluding elements of Set X */ @Override public void foreachExcluding(IntSet X, IntSetAction action) { sparsePart.foreachExcluding(X, action); if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { if (!X.contains(b)) { action.act(b); } } } }
/** * Invoke an action on each element of the Set, excluding elements of Set X */ @Override public void foreachExcluding(IntSet X, IntSetAction action) { sparsePart.foreachExcluding(X, action); if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { if (!X.contains(b)) { action.act(b); } } } }
/** * Invoke an action on each element of the Set, excluding elements of Set X */ @Override public void foreachExcluding(IntSet X, IntSetAction action) { sparsePart.foreachExcluding(X, action); if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { if (!X.contains(b)) { action.act(b); } } } }
/** * @return true iff {@code this} has the same value as {@code that}. * @throws IllegalArgumentException if that is null */ @Override public boolean sameValue(IntSet that) { if (that == null) { throw new IllegalArgumentException("that is null"); } if (size() != that.size()) { return false; } if (densePart != null) { for (int bit = densePart.nextSetBit(0); bit != -1; bit = densePart.nextSetBit(bit + 1)) { if (!that.contains(bit)) { return false; } } } for (IntIterator bits = sparsePart.intIterator(); bits.hasNext();) { if (!that.contains(bits.next())) { return false; } } return true; }
/** * @return true iff {@code this} is a subset of {@code that}. * @throws IllegalArgumentException if that is null */ @Override public boolean isSubset(IntSet that) { if (that == null) { throw new IllegalArgumentException("that is null"); } if (size() > that.size()) { return false; } for (IntIterator bits = sparsePart.intIterator(); bits.hasNext();) { if (!that.contains(bits.next())) { return false; } } if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { if (!that.contains(b)) { return false; } } } return true; }
/** * @return true iff {@code this} has the same value as {@code that}. * @throws IllegalArgumentException if that is null */ @Override public boolean sameValue(IntSet that) { if (that == null) { throw new IllegalArgumentException("that is null"); } if (size() != that.size()) { return false; } if (densePart != null) { for (int bit = densePart.nextSetBit(0); bit != -1; bit = densePart.nextSetBit(bit + 1)) { if (!that.contains(bit)) { return false; } } } for (IntIterator bits = sparsePart.intIterator(); bits.hasNext();) { if (!that.contains(bits.next())) { return false; } } return true; }
/** * @return true iff {@code this} has the same value as {@code that}. * @throws IllegalArgumentException if that is null */ @Override public boolean sameValue(IntSet that) { if (that == null) { throw new IllegalArgumentException("that is null"); } if (size() != that.size()) { return false; } if (densePart != null) { for (int bit = densePart.nextSetBit(0); bit != -1; bit = densePart.nextSetBit(bit + 1)) { if (!that.contains(bit)) { return false; } } } for (IntIterator bits = sparsePart.intIterator(); bits.hasNext();) { if (!that.contains(bits.next())) { return false; } } return true; }
/** * @return true iff {@code this} is a subset of {@code that}. * @throws IllegalArgumentException if that is null */ @Override public boolean isSubset(IntSet that) { if (that == null) { throw new IllegalArgumentException("that is null"); } if (size() > that.size()) { return false; } for (IntIterator bits = sparsePart.intIterator(); bits.hasNext();) { if (!that.contains(bits.next())) { return false; } } if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { if (!that.contains(b)) { return false; } } } return true; }
/** * @return true iff {@code this} is a subset of {@code that}. * @throws IllegalArgumentException if that is null */ @Override public boolean isSubset(IntSet that) { if (that == null) { throw new IllegalArgumentException("that is null"); } if (size() > that.size()) { return false; } for (IntIterator bits = sparsePart.intIterator(); bits.hasNext();) { if (!that.contains(bits.next())) { return false; } } if (densePart != null) { for (int b = densePart.nextSetBit(0); b != -1; b = densePart.nextSetBit(b + 1)) { if (!that.contains(b)) { return false; } } } return true; }
/** * Remove an integer from this set. * * @param i integer to remove * @return true iff the value of this changes. */ @Override public boolean remove(int i) { if (densePart != null && densePart.get(i)) { densePart.clear(i); if (densePart.nextSetBit(0) == -1) { densePart = null; } return true; } else if (sparsePart.contains(i)) { sparsePart.remove(i); return true; } else { return false; } }
/** * Remove an integer from this set. * * @param i integer to remove * @return true iff the value of this changes. */ @Override public boolean remove(int i) { if (densePart != null && densePart.get(i)) { densePart.clear(i); if (densePart.nextSetBit(0) == -1) { densePart = null; } return true; } else if (sparsePart.contains(i)) { sparsePart.remove(i); return true; } else { return false; } }
/** * Remove an integer from this set. * * @param i integer to remove * @return true iff the value of this changes. */ @Override public boolean remove(int i) { if (densePart != null && densePart.get(i)) { densePart.clear(i); if (densePart.nextSetBit(0) == -1) { densePart = null; } return true; } else if (sparsePart.contains(i)) { sparsePart.remove(i); return true; } else { return false; } }