public static <T> PrimitiveIntObjectMap<T> copy( PrimitiveIntObjectMap<T> original ) { PrimitiveIntObjectMap<T> copy = Primitive.intObjectMap( original.size() ); original.visitEntries( ( key, value ) -> { copy.put( key, value ); return false; } ); return copy; }
public static <T> PrimitiveLongObjectMap<T> copy( PrimitiveLongObjectMap<T> original ) { PrimitiveLongObjectMap<T> copy = Primitive.longObjectMap( original.size() ); original.visitEntries( ( key, value ) -> { copy.put( key, value ); return false; } ); return copy; }
@Override public boolean hasNext() { return source.hasNext(); }
@Override public boolean hasNext() { return delegate.hasNext(); }
/** * If the given obj is AutoCloseable, then close it. * Any exceptions thrown from the close method will be wrapped in RuntimeExceptions. */ static void closeSafely( Object obj ) { closeSafely( obj, null ); }
@Override public PrimitiveLongIterator iterator() { return new PrimitiveLongArrayQueueIterator(); }
public void push( int value ) { ensureCapacity(); array[++cursor] = value; }
public void add( long element ) { if ( elements.length == size ) { ensureCapacity(); } elements[size++] = element; }
/** * Pulls all items from the {@code iterator} and puts them into a {@link Set}, boxing each int. * Any duplicate value will throw {@link IllegalStateException}. * * @param iterator {@link PrimitiveIntIterator} to pull values from. * @return a {@link Set} containing all items. * @throws IllegalStateException for the first encountered duplicate. */ public static Set<Integer> toSet( PrimitiveIntIterator iterator ) { return mapToSet( iterator, Integer::new ); }
@Override public void close() { set.close(); } }