/** * Perform a {@link #remove(Object)} of all values in <var>array</var> * @param array The array whose contents are to be removed. */ public boolean removeAll(ArraySet<? extends E> array) { // TODO: If array is sufficiently large, a marking approach might be beneficial. In a first // pass, use the property that the sets are sorted by hash to make this linear passes // (except for hash collisions, which means worst case still n*m), then do one // collection pass into a new array. This avoids binary searches and excessive memcpy. final int N = array.mSize; // Note: ArraySet does not make thread-safety guarantees. So instead of OR-ing together all // the single results, compare size before and after. final int originalSize = mSize; for (int i = 0; i < N; i++) { remove(array.valueAt(i)); } return originalSize != mSize; }
/** * {@inheritDoc} * * <p>This implementation composes a string by iterating over its values. If * this set contains itself as a value, the string "(this Set)" * will appear in its place. */ @Override public String toString() { if (isEmpty()) { return "{}"; } StringBuilder buffer = new StringBuilder(mSize * 14); buffer.append('{'); for (int i=0; i<mSize; i++) { if (i > 0) { buffer.append(", "); } Object value = valueAt(i); if (value != this) { buffer.append(value); } else { buffer.append("(this Set)"); } } buffer.append('}'); return buffer.toString(); }
E mine = valueAt(i); if (!set.contains(mine)) { return false;
/** * Perform a {@link #add(Object)} of all values in <var>array</var> * @param array The array whose contents are to be retrieved. */ public void addAll(ArraySet<? extends E> array) { final int N = array.mSize; ensureCapacity(mSize + N); if (mSize == 0) { if (N > 0) { System.arraycopy(array.mHashes, 0, mHashes, 0, N); System.arraycopy(array.mArray, 0, mArray, 0, N); mSize = N; } } else { for (int i=0; i<N; i++) { add(array.valueAt(i)); } } }
/** * Perform a {@link #remove(Object)} of all values in <var>array</var> * @param array The array whose contents are to be removed. */ public boolean removeAll(ArraySet<? extends E> array) { // TODO: If array is sufficiently large, a marking approach might be beneficial. In a first // pass, use the property that the sets are sorted by hash to make this linear passes // (except for hash collisions, which means worst case still n*m), then do one // collection pass into a new array. This avoids binary searches and excessive memcpy. final int N = array.mSize; // Note: ArraySet does not make thread-safety guarantees. So instead of OR-ing together all // the single results, compare size before and after. final int originalSize = mSize; for (int i = 0; i < N; i++) { remove(array.valueAt(i)); } return originalSize != mSize; }
/** * Perform a {@link #remove(Object)} of all values in <var>array</var> * @param array The array whose contents are to be removed. */ public boolean removeAll(ArraySet<? extends E> array) { // TODO: If array is sufficiently large, a marking approach might be beneficial. In a first // pass, use the property that the sets are sorted by hash to make this linear passes // (except for hash collisions, which means worst case still n*m), then do one // collection pass into a new array. This avoids binary searches and excessive memcpy. final int N = array.mSize; // Note: ArraySet does not make thread-safety guarantees. So instead of OR-ing together all // the single results, compare size before and after. final int originalSize = mSize; for (int i = 0; i < N; i++) { remove(array.valueAt(i)); } return originalSize != mSize; }
/** * {@inheritDoc} * * <p>This implementation composes a string by iterating over its values. If * this set contains itself as a value, the string "(this Set)" * will appear in its place. */ @Override public String toString() { if (isEmpty()) { return "{}"; } StringBuilder buffer = new StringBuilder(mSize * 14); buffer.append('{'); for (int i=0; i<mSize; i++) { if (i > 0) { buffer.append(", "); } Object value = valueAt(i); if (value != this) { buffer.append(value); } else { buffer.append("(this Set)"); } } buffer.append('}'); return buffer.toString(); }
/** * {@inheritDoc} * * <p>This implementation composes a string by iterating over its values. If * this set contains itself as a value, the string "(this Set)" * will appear in its place. */ @Override public String toString() { if (isEmpty()) { return "{}"; } StringBuilder buffer = new StringBuilder(mSize * 14); buffer.append('{'); for (int i=0; i<mSize; i++) { if (i > 0) { buffer.append(", "); } Object value = valueAt(i); if (value != this) { buffer.append(value); } else { buffer.append("(this Set)"); } } buffer.append('}'); return buffer.toString(); }
E mine = valueAt(i); if (!set.contains(mine)) { return false;
E mine = valueAt(i); if (!set.contains(mine)) { return false;
/** * Perform a {@link #add(Object)} of all values in <var>array</var> * @param array The array whose contents are to be retrieved. */ public void addAll(ArraySet<? extends E> array) { final int N = array.mSize; ensureCapacity(mSize + N); if (mSize == 0) { if (N > 0) { System.arraycopy(array.mHashes, 0, mHashes, 0, N); System.arraycopy(array.mArray, 0, mArray, 0, N); mSize = N; } } else { for (int i=0; i<N; i++) { add(array.valueAt(i)); } } }
/** * Perform a {@link #add(Object)} of all values in <var>array</var> * @param array The array whose contents are to be retrieved. */ public void addAll(ArraySet<? extends E> array) { final int N = array.mSize; ensureCapacity(mSize + N); if (mSize == 0) { if (N > 0) { System.arraycopy(array.mHashes, 0, mHashes, 0, N); System.arraycopy(array.mArray, 0, mArray, 0, N); mSize = N; } } else { for (int i=0; i<N; i++) { add(array.valueAt(i)); } } }