@Override public <T> T[] toArray(T[] a) {
        Object[] kvs = raw_array();
        // Estimate size of array; be prepared to see more or fewer elements
        int sz = size();
        T[] r = a.length >= sz ? a :
          (T[])java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), sz);
        // Fast efficient element walk.
        int j=0;
        for( int i=0; i<len(kvs); i++ ) {
          Object K = key(kvs,i);
          Object V = Prime.unbox(val(kvs,i));
          if( K != null && K != TOMBSTONE && V != null && V != TOMBSTONE ) {
            if( j >= r.length ) {
              int sz2 = (int)Math.min(Integer.MAX_VALUE-8,((long)j)<<1);
              if( sz2<=r.length ) throw new OutOfMemoryError("Required array size too large");
              r = Arrays.copyOf(r,sz2);
            }
            r[j++] = (T)K;
          }
        }
        if( j <= a.length ) {   // Fit in the original array?
          if( a!=r ) System.arraycopy(r,0,a,0,j);
          if( j<a.length ) r[j++]=null; // One final null not in the spec but in the default impl
          return a;             // Return the original
        }
        return Arrays.copyOf(r,j);
      }
Returns a {@link Set} view of the keys contained in this map.  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.
jctools-core/src/main/java/org/jctools/maps/NonBlockingHashMap.java