public long[] getSnapshotAndClear() { final Set<Long> set = map.keySet(); final long[] array = new long[set.size()]; int i=0; for(NonBlockingHashMapLong.IteratorLong it = (NonBlockingHashMapLong.IteratorLong)set.iterator(); it.hasNext(); ) { array[i] = it.nextLong(); it.remove(); i++; } assert i == array.length; return array; } }
/** Returns a {@link Set} view of the keys contained in this map; with care * the keys may be iterated over <strong>without auto-boxing</strong>. The * set is backed by the map, so changes to the map are reflected in the * set, and vice-versa. The set supports element removal, which removes * the corresponding mapping from this map, via the * <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, <tt>removeAll</tt>, * <tt>retainAll</tt>, and <tt>clear</tt> operations. It does not support * the <tt>add</tt> or <tt>addAll</tt> operations. * * <p>The view's <tt>iterator</tt> is a "weakly consistent" iterator that * will never throw {@link ConcurrentModificationException}, and guarantees * to traverse elements as they existed upon construction of the iterator, * and may (but is not guaranteed to) reflect any modifications subsequent * to construction. */ public Set<Long> keySet() { return new AbstractSet<Long> () { public void clear ( ) { NonBlockingHashMapLong.this.clear ( ); } public int size ( ) { return NonBlockingHashMapLong.this.size ( ); } public boolean contains( Object k ) { return NonBlockingHashMapLong.this.containsKey(k); } public boolean remove ( Object k ) { return NonBlockingHashMapLong.this.remove (k) != null; } public IteratorLong iterator() { return new IteratorLong(); } }; }
/** Returns a {@link Set} view of the keys contained in this map; with care * the keys may be iterated over <strong>without auto-boxing</strong>. The * set is backed by the map, so changes to the map are reflected in the * set, and vice-versa. The set supports element removal, which removes * the corresponding mapping from this map, via the * <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, <tt>removeAll</tt>, * <tt>retainAll</tt>, and <tt>clear</tt> operations. It does not support * the <tt>add</tt> or <tt>addAll</tt> operations. * * <p>The view's <tt>iterator</tt> is a "weakly consistent" iterator that * will never throw {@link ConcurrentModificationException}, and guarantees * to traverse elements as they existed upon construction of the iterator, * and may (but is not guaranteed to) reflect any modifications subsequent * to construction. */ public Set<Long> keySet() { return new AbstractSet<Long> () { public void clear ( ) { NonBlockingHashMapLong.this.clear ( ); } public int size ( ) { return NonBlockingHashMapLong.this.size ( ); } public boolean contains( Object k ) { return NonBlockingHashMapLong.this.containsKey(k); } public boolean remove ( Object k ) { return NonBlockingHashMapLong.this.remove (k) != null; } public IteratorLong iterator() { return new IteratorLong(); } }; }
/** Returns a {@link Set} view of the keys contained in this map; with care * the keys may be iterated over <strong>without auto-boxing</strong>. The * set is backed by the map, so changes to the map are reflected in the * set, and vice-versa. The set supports element removal, which removes * the corresponding mapping from this map, via the * <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, <tt>removeAll</tt>, * <tt>retainAll</tt>, and <tt>clear</tt> operations. It does not support * the <tt>add</tt> or <tt>addAll</tt> operations. * * <p>The view's <tt>iterator</tt> is a "weakly consistent" iterator that * will never throw {@link ConcurrentModificationException}, and guarantees * to traverse elements as they existed upon construction of the iterator, * and may (but is not guaranteed to) reflect any modifications subsequent * to construction. */ public Set<Long> keySet() { return new AbstractSet<Long> () { public void clear ( ) { NonBlockingHashMapLong.this.clear ( ); } public int size ( ) { return NonBlockingHashMapLong.this.size ( ); } public boolean contains( Object k ) { return NonBlockingHashMapLong.this.containsKey(k); } public boolean remove ( Object k ) { return NonBlockingHashMapLong.this.remove (k) != null; } public IteratorLong iterator() { return new IteratorLong(); } }; }
public IteratorLong iterator() { return new IteratorLong(); } };
public IteratorLong iterator() { return new IteratorLong(); } };
public IteratorLong iterator() { return new IteratorLong(); } };
/** Returns an enumeration of the <strong>auto-boxed</strong> keys in this table. * <strong>Warning:</strong> this version will auto-box all returned keys. * @return an enumeration of the auto-boxed keys in this table * @see #keySet() */ public Enumeration<Long> keys() { return new IteratorLong(); }
/** Returns an enumeration of the <strong>auto-boxed</strong> keys in this table. * <strong>Warning:</strong> this version will auto-box all returned keys. * @return an enumeration of the auto-boxed keys in this table * @see #keySet() */ public Enumeration<Long> keys() { return new IteratorLong(); }
/** Returns an enumeration of the <strong>auto-boxed</strong> keys in this table. * <strong>Warning:</strong> this version will auto-box all returned keys. * @return an enumeration of the auto-boxed keys in this table * @see #keySet() */ public Enumeration<Long> keys() { return new IteratorLong(); }