Used during union operations to ensure we do not overwrite an existing reservoir. Creates a
shallow copy of the reservoir.

@return A copy of the current sketch
540659
@SuppressWarnings("unchecked")
  ReservoirItemsSketch<T> copy() {
    return new ReservoirItemsSketch<>(reservoirSize_, currItemsAlloc_,
            itemsSeen_, rf_, (ArrayList<T>) data_.clone());
  }
568436
def copy(self):
    
    if self._iters:
      a, b = it.tee(self._iters[0])
      self._iters[0] = a
      return Stream(b)
    iter(self)
771517
public synchronized DTMIterator getInstanceOrThrow()
    throws CloneNotSupportedException
  {
    // Check if the pool is empty.
    if (m_freeStack.isEmpty())
    {

      // Create a new object if so.
      return (DTMIterator)m_orig.clone();
    }
    else
    {
      // Remove object from end of free pool.
      DTMIterator result = (DTMIterator)m_freeStack.remove(m_freeStack.size() - 1);
      return result;
    }
  }
543361
CpcSketch copy() {
    final CpcSketch copy = new CpcSketch(lgK, seed);
    copy.numCoupons = numCoupons;
    copy.mergeFlag = mergeFlag;
    copy.fiCol = fiCol;

    copy.windowOffset = windowOffset;
    copy.slidingWindow = (slidingWindow == null) ? null : slidingWindow.clone();
    copy.pairTable = (pairTable == null) ? null : pairTable.copy();

    copy.kxp = kxp;
    copy.hipEstAccum = hipEstAccum;
    return copy;
  }
918484
public MapField<K, V> copy() {
        return new MapField<K, V>(converter, StorageMode.MAP, MapFieldLite.copy(getMap()), null);
    }
1274547
public PropertyDescriptorImpl shallowCopy() {
    final ConstraintDescriptorImpl<?>[] desc = new ConstraintDescriptorImpl<?>[descriptors.size()];
    descriptors.toArray(desc);
    return new PropertyDescriptorImpl( //
        name, //
        elementClass, //
        cascaded, //
        parentBeanMetadata, //
        validationGroupsMetadata, //
        desc);
  }
585016
public T borrowObject() {
		T object;
		if ((object = pool.poll()) == null) {
			object = createObject();
		}

		return object;
	}
794298
def copy(self):
        
        # use the geometries copy method to
        # allow them to handle references to unpickle-able objects
        geometry = {n: g.copy() for n, g in self.geometry.items()}
        # create a new scene with copied geometry and graph
        copied = Scene(geometry=geometry,
                       graph=self.graph.copy())
        return copied
727754
@Override
    public Model copy() {
        DefaultModel m = new DefaultModel(eb.copy());
        MappingUtils.fill(sm, m.getMapping());
        for (ModelView rc : parent.getViews()) {
            m.attach(rc.copy());
        }
        m.setAttributes(this.getAttributes().copy());
        return m;
    }
880920
public Matrix copy()
    {
        Matrix X = new Matrix(m, n);
        double[][] C = X.getArray();
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < n; j++)
            {
                C[i][j] = A[i][j];
            }
        }
        return X;
    }
786111
protected UDPBufferImpl getUDPBufferImpl() {
        UDPBufferImpl ret = (UDPBufferImpl) udpBufferObjectPool.get();
        if (ret == null) {
            ret = new UDPBufferImpl(this);
        }
        return ret;
    }
254858
public JMFMessage copy() {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.entry(this, tc, "copy");
    JMFMessage copy;

    synchronized (getMessageLockArtefact()) {
      if (map == null) {
        // If there is no map, then this is already become just a delegator, so
        // the copy does not need to include the compatibility wrapper.
        copy = ((JMFMessage)encoding).copy();
      }
      else {
        // In the usual case, we maintain a compatibility layer
        copy = new JSCompatibleMessageImpl(this);
      }
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.exit(this, tc, "copy", copy);
    return copy;
  }
864711
public DTMIterator cloneWithReset() throws CloneNotSupportedException
  {
    LocPathIterator clone;
//    clone = (LocPathIterator) clone();
    clone = (LocPathIterator)m_clones.getInstanceOrThrow();
    clone.m_execContext = m_execContext;
    clone.m_cdtm = m_cdtm;
    
    clone.m_context = m_context;
    clone.m_currentContextNode = m_currentContextNode;
    clone.m_stackFrame = m_stackFrame;

    // clone.reset();

    return clone;
  }
361581
public void update(final ReservoirLongsSketch sketchIn) {
    if (sketchIn == null) {
      return;
    }

    final ReservoirLongsSketch rls =
        (sketchIn.getK() <= maxK_ ? sketchIn : sketchIn.downsampledCopy(maxK_));

    // can modify the sketch if we downsampled, otherwise may need to copy it
    final boolean isModifiable = (sketchIn != rls);
    if (gadget_ == null) {
      createNewGadget(rls, isModifiable);
    } else {
      twoWayMergeInternal(rls, isModifiable);
    }
  }
986287
public ContentAssistContext.Builder copy() {
		Builder result = builderProvider.get();
		result.copyFrom(this);
		return result;
	}
790355
public WrappedByteBuffer compact() {
        int remaining = remaining();
        int capacity = capacity();

        if (capacity == 0) {
            return this;
        }

        if (remaining <= capacity >>> 2 && capacity > _minimumCapacity) {
            int newCapacity = capacity;
            int minCapacity = max(_minimumCapacity, remaining << 1);
            for (;;) {
                if (newCapacity >>> 1 < minCapacity) {
                    break;
                }
                newCapacity >>>= 1;
            }

            newCapacity = max(minCapacity, newCapacity);

            if (newCapacity == capacity) {
                if (_buf.remaining() == 0) {
                    _buf.position(0);
                    _buf.limit(_buf.capacity());                    
                }
                else {
                    java.nio.ByteBuffer dup = _buf.duplicate();
                    _buf.position(0);
                    _buf.limit(_buf.capacity());
                    _buf.put(dup);
                }
                return this;
            }

            // Shrink and compact:
            // // Save the state.
            ByteOrder bo = order();

            // // Sanity check.
            if (remaining > newCapacity) {
                throw new IllegalStateException("The amount of the remaining bytes is greater than " + "the new capacity.");
            }

            // // Reallocate.
            java.nio.ByteBuffer oldBuf = _buf;
            java.nio.ByteBuffer newBuf = java.nio.ByteBuffer.allocate(newCapacity);
            newBuf.put(oldBuf);
            _buf = newBuf;

            // // Restore the state.
            _buf.order(bo);
        } else {
            _buf.compact();
        }

        return this;
    }
148965
public SessionContext copy()
    {
        SessionContext copy = new SessionContext();
        copy.brownoutMode = brownoutMode;
        copy.cancelled = cancelled;
        copy.shouldStopFilterProcessing = shouldStopFilterProcessing;
        copy.shouldSendErrorResponse = shouldSendErrorResponse;
        copy.errorResponseSent = errorResponseSent;
        copy.debugRouting = debugRouting;
        copy.debugRequest = debugRequest;
        copy.debugRequestHeadersOnly = debugRequestHeadersOnly;
        copy.timings = timings;

        Iterator<String> it = keySet().iterator();
        String key = it.next();
        while (key != null) {
            Object orig = get(key);
            try {
                Object copyValue = DeepCopy.copy(orig);
                if (copyValue != null) {
                    copy.set(key, copyValue);
                } else {
                    copy.set(key, orig);
                }
            } catch (NotSerializableException e) {
                copy.set(key, orig);
            }
            if (it.hasNext()) {
                key = it.next();
            } else {
                key = null;
            }
        }
        return copy;
    }