Example #1
0
  /**
   * Produces a shallow copy of this vector.
   *
   * @return the new vector
   */
  public final Object copy() {

    FastVector copy = new FastVector(m_Objects.length, m_CapacityIncrement, m_CapacityMultiplier);
    copy.m_Size = m_Size;
    System.arraycopy(m_Objects, 0, copy.m_Objects, 0, m_Size);
    return copy;
  }
Example #2
0
  /**
   * Clones the vector and shallow copies all its elements. The elements have to implement the
   * Copyable interface.
   *
   * @return the new vector
   */
  public final Object copyElements() {

    FastVector copy = new FastVector(m_Objects.length, m_CapacityIncrement, m_CapacityMultiplier);
    copy.m_Size = m_Size;
    for (int i = 0; i < m_Size; i++) {
      copy.m_Objects[i] = ((Copyable) m_Objects[i]).copy();
    }
    return copy;
  }