@Override public boolean contains(int i) { if (privatePart != null && privatePart.contains(i)) { return true; } if (sharedPart != null && sharedPart.contains(i)) { return true; } return false; }
@Override public boolean contains(int i) { if (privatePart != null && privatePart.contains(i)) { return true; } if (sharedPart != null && sharedPart.contains(i)) { return true; } return false; }
@Override public boolean contains(int i) { if (privatePart != null && privatePart.contains(i)) { return true; } if (sharedPart != null && sharedPart.contains(i)) { return true; } return false; }
/** * @return true iff this set contains integer i */ @Override public boolean contains(int i) { if (densePart != null && inDenseRange(i)) { return densePart.contains(i); } else { return sparsePart.contains(i); } }
/** * @return true iff this set contains integer i */ @Override public boolean contains(int i) { if (densePart != null && inDenseRange(i)) { return densePart.contains(i); } else { return sparsePart.contains(i); } }
/** * @return true iff this set contains integer i */ @Override public boolean contains(int i) { if (densePart != null && inDenseRange(i)) { return densePart.contains(i); } else { return sparsePart.contains(i); } }
/** * Add all elements from another int set. * * @return true iff this set changes * @throws IllegalArgumentException * if set == null */ @Override @SuppressWarnings("unused") public boolean addAll(IntSet set) throws IllegalArgumentException { if (set == null) { throw new IllegalArgumentException("set == null"); } if (set instanceof SparseIntSet) { return addAll((SparseIntSet) set); } else { int oldSize = size; set.foreach(i -> { if (!contains(i)) add(i); }); if (DEBUG_LARGE && size() > TRAP_SIZE) { Assertions.UNREACHABLE(); } return size != oldSize; } }
/** * Add all elements from another int set. * * @return true iff this set changes * @throws IllegalArgumentException * if set == null */ @Override @SuppressWarnings("unused") public boolean addAll(IntSet set) throws IllegalArgumentException { if (set == null) { throw new IllegalArgumentException("set == null"); } if (set instanceof SparseIntSet) { return addAll((SparseIntSet) set); } else { int oldSize = size; set.foreach(i -> { if (!contains(i)) add(i); }); if (DEBUG_LARGE && size() > TRAP_SIZE) { Assertions.UNREACHABLE(); } return size != oldSize; } }
/** * 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; } }
@Override public IntIterator intIterator() { MutableSparseIntSet bits = MutableSparseIntSet.makeEmpty(); for (IntIterator pi = primaryImpl.intIterator(); pi.hasNext();) { int x = pi.next(); assert !bits.contains(x); bits.add(x); } for (IntIterator si = secondaryImpl.intIterator(); si.hasNext();) { int x = si.next(); assert bits.contains(x); bits.remove(x); } assert bits.isEmpty(); return primaryImpl.intIterator(); }
@Override public IntIterator intIterator() { MutableSparseIntSet bits = MutableSparseIntSet.makeEmpty(); for (IntIterator pi = primaryImpl.intIterator(); pi.hasNext();) { int x = pi.next(); assert !bits.contains(x); bits.add(x); } for (IntIterator si = secondaryImpl.intIterator(); si.hasNext();) { int x = si.next(); assert bits.contains(x); bits.remove(x); } assert bits.isEmpty(); return primaryImpl.intIterator(); }
@Override public IntIterator intIterator() { MutableSparseIntSet bits = MutableSparseIntSet.makeEmpty(); for (IntIterator pi = primaryImpl.intIterator(); pi.hasNext();) { int x = pi.next(); assert !bits.contains(x); bits.add(x); } for (IntIterator si = secondaryImpl.intIterator(); si.hasNext();) { int x = si.next(); assert bits.contains(x); bits.remove(x); } assert bits.isEmpty(); return primaryImpl.intIterator(); }
@Override public boolean remove(int i) { if (privatePart != null) { if (privatePart.contains(i)) { privatePart.remove(i); if (privatePart.size() == 0) { privatePart = null; } return true; } } if (sharedPart != null) { if (sharedPart.contains(i)) { privatePart = makeSparseCopy(); privatePart.remove(i); if (privatePart.size() == 0) { privatePart = null; } sharedPart = null; checkOverflow(); return true; } } return false; }
@Override public boolean remove(int i) { if (privatePart != null) { if (privatePart.contains(i)) { privatePart.remove(i); if (privatePart.size() == 0) { privatePart = null; } return true; } } if (sharedPart != null) { if (sharedPart.contains(i)) { privatePart = makeSparseCopy(); privatePart.remove(i); if (privatePart.size() == 0) { privatePart = null; } sharedPart = null; checkOverflow(); return true; } } return false; }
@Override public boolean remove(int i) { if (privatePart != null) { if (privatePart.contains(i)) { privatePart.remove(i); if (privatePart.size() == 0) { privatePart = null; } return true; } } if (sharedPart != null) { if (sharedPart.contains(i)) { privatePart = makeSparseCopy(); privatePart.remove(i); if (privatePart.size() == 0) { privatePart = null; } sharedPart = null; checkOverflow(); return true; } } return false; }
/** * Add an integer value to this set. * * @param i integer to add * @return true iff the value of this changes. */ @Override public boolean add(int i) { if (densePart != null && inDenseRange(i)) { if (!densePart.get(i)) { densePart.set(i); assert assertDisjoint() : this.toString(); return true; } } else if (!sparsePart.contains(i)) { sparsePart.add(i); assert assertDisjoint() : this.toString(); fixAfterSparseInsert(); return true; } return false; }
/** * Add an integer value to this set. * * @param i integer to add * @return true iff the value of this changes. */ @Override public boolean add(int i) { if (densePart != null && inDenseRange(i)) { if (!densePart.get(i)) { densePart.set(i); assert assertDisjoint() : this.toString(); return true; } } else if (!sparsePart.contains(i)) { sparsePart.add(i); assert assertDisjoint() : this.toString(); fixAfterSparseInsert(); return true; } return false; }
/** * Add an integer value to this set. * * @param i integer to add * @return true iff the value of this changes. */ @Override public boolean add(int i) { if (densePart != null && inDenseRange(i)) { if (!densePart.get(i)) { densePart.set(i); assert assertDisjoint() : this.toString(); return true; } } else if (!sparsePart.contains(i)) { sparsePart.add(i); assert assertDisjoint() : this.toString(); fixAfterSparseInsert(); return true; } return false; }