/** * Returns an iterator over the elements contained in this collection. * No element from this set will be garbage collected as long as a * reference to the iterator is hold. * * @return an iterator over all elements in this set. */ @Override public Iterator<E> iterator() { return Arrays.asList(toArray()).iterator(); } }
/** * Returns an iterator over the elements contained in this collection. * No element from this set will be garbage collected as long as a * reference to the iterator is hold. * * @return an iterator over all elements in this set. */ @Override public Iterator<E> iterator() { return Arrays.asList(toArray()).iterator(); } }
/** * Returns an array containing every instances of this type that have not yet been * garbage collected. The first elements of the returned array are the constants * defined in this class, in declaration order. All other elements are the instances * created by the {@link #valueOf(String)} method, in no particular order. * * @return an array containing the instances of {@code NilReason}. */ public static NilReason[] values() { final int predefinedCount = PREDEFINED.length; NilReason[] reasons; synchronized (POOL) { reasons = POOL.toArray(new NilReason[predefinedCount + POOL.size()]); } int count = reasons.length; while (count != 0 && reasons[count-1] == null) { count--; } count += predefinedCount; final NilReason[] source = reasons; if (count != reasons.length) { reasons = new NilReason[count]; } System.arraycopy(source, 0, reasons, predefinedCount, count - predefinedCount); System.arraycopy(PREDEFINED, 0, reasons, 0, predefinedCount); return reasons; }
/** * Returns an array containing every instances of this type that have not yet been * garbage collected. The first elements of the returned array are the constants * defined in this class, in declaration order. All other elements are the instances * created by the {@link #valueOf(String)} method, in no particular order. * * @return an array containing the instances of {@code NilReason}. */ public static NilReason[] values() { final int predefinedCount = PREDEFINED.length; NilReason[] reasons; synchronized (POOL) { reasons = POOL.toArray(new NilReason[predefinedCount + POOL.size()]); } int count = reasons.length; while (count != 0 && reasons[count-1] == null) { count--; } count += predefinedCount; final NilReason[] source = reasons; if (count != reasons.length) { reasons = new NilReason[count]; } System.arraycopy(source, 0, reasons, predefinedCount, count - predefinedCount); System.arraycopy(PREDEFINED, 0, reasons, 0, predefinedCount); return reasons; }