/** * Returns <tt>true</tt> if this set contains the specified elements. * * @param o element whose presence in this set to be tested * @return <tt>true</tt> if this set contains the specified element */ @Override public boolean contains(Object o) { if (o == null) { return false; } if (!(o instanceof Integer)) return false; Integer i = (Integer) o; if (i < 0) throw new RuntimeException("i < 0: " + i); checkInvariants(); int wordIndex = wordIndex(i); return (wordIndex < wordsInUse) && ((words[wordIndex] & (1L << i)) != 0); }
/** * Removes the specified element from this set if it is present. * * @param o object to be removed from this set, if present * @return <tt>true</tt> if the set contained the specified element */ @Override public boolean remove(Object o) { if (!(o instanceof Integer)) { return false; } Integer i = (Integer) o; if (i < 0) return false; if (!contains(i)) { return false; } int wordIndex = wordIndex(i); if (wordIndex >= wordsInUse) return false; words[wordIndex] &= ~(1L << i); --size; modCount++; recalculateWordsInUse(); checkInvariants(); return true; }