@Override public boolean add(final int k) { synchronized (sync) { return collection.add(k); } } @Override
@Override @Deprecated public boolean add(final Integer k) { synchronized (sync) { return collection.add(k); } } @Override
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @SuppressWarnings("deprecation") @Deprecated @Override public boolean add(final Integer key) { return IntCollection.super.add(key); } /**
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @SuppressWarnings("deprecation") @Deprecated @Override default boolean add(final Integer o) { return IntCollection.super.add(o); } /**
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default boolean add(final Integer key) { return add((key).intValue()); } /**
/** * Adds a value for a given key. * * @param key * The key to add the new value to. * @param value * The value to add. * @return {@code true} iff the value was successfully added. */ public boolean putValue(final K key, final int value) { final C values = getValues(key); final boolean result = values.add(value); if (result) { allValues.add(value); } return result; }
public void put(T key, int value) { IntCollection collection = map.computeIfAbsent(key, k -> new IntLinkedOpenHashSet(2, .75f)); collection.add(value); }
/** * Pours an iterator into a type-specific collection, with a limit on the number * of elements. * * <p> * This method iterates over the given type-specific iterator and adds the * returned elements to the given collection (up to {@code max}). * * @param i * a type-specific iterator. * @param s * a type-specific collection. * @param max * the maximum number of elements to be poured. * @return the number of elements poured. Note that this is the number of * elements returned by the iterator, which is not necessarily the * number of elements that have been added to the collection (because of * duplicates). */ public static int pour(final IntIterator i, final IntCollection s, final int max) { if (max < 0) throw new IllegalArgumentException("The maximum number of elements (" + max + ") is negative"); int j = max; while (j-- != 0 && i.hasNext()) s.add(i.nextInt()); return max - j - 1; } /**
int j = max; while (j-- != 0 && i.hasNext()) c.add(i.nextInt()); return max - j - 1;
/** * Unwraps an iterator into a type-specific collection. * * <p> * This method iterates over the given type-specific iterator and stores the * elements returned in the given type-specific collection. The returned count * on the number unwrapped elements is a long, so that it will work also with * very large collections. * * @param i * a type-specific iterator. * @param c * a type-specific collection to contain the output of the iterator. * @return the number of elements unwrapped. Note that this is the number of * elements returned by the iterator, which is not necessarily the * number of elements that have been added to the collection (because of * duplicates). */ public static long unwrap(final IntIterator i, final IntCollection c) { long n = 0; while (i.hasNext()) { c.add(i.nextInt()); n++; } return n; } /**
final boolean wasAdded = incrementedValues.add(valueToIncrement); assert wasAdded;
final boolean wasAdded = incrementedValues.add(valueToIncrement); assert wasAdded;