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

    FastVector copy = new FastVector(m_Objects.length);

    copy.m_Size = m_Size;
    copy.m_CapacityIncrement = m_CapacityIncrement;
    copy.m_CapacityMultiplier = m_CapacityMultiplier;
    System.arraycopy(m_Objects, 0, copy.m_Objects, 0, m_Size);
    return copy;
  }
Exemple #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);

    copy.m_Size = m_Size;
    copy.m_CapacityIncrement = m_CapacityIncrement;
    copy.m_CapacityMultiplier = m_CapacityMultiplier;
    for (int i = 0; i < m_Size; i++) {
      copy.m_Objects[i] = ((Copyable) m_Objects[i]).copy();
    }
    return copy;
  }
Exemple #3
0
    /**
     * Tests if there are any more elements to enumerate.
     *
     * @return true if there are some elements left
     */
    public final /*@pure@*/ boolean hasMoreElements() {

      if (m_Counter < m_Vector.size()) {
        return true;
      }
      return false;
    }
Exemple #4
0
    // @ also requires hasMoreElements();
    public final Object nextElement() {

      Object result = m_Vector.elementAt(m_Counter);

      m_Counter++;
      if (m_Counter == m_SpecialElement) {
        m_Counter++;
      }
      return result;
    }
Exemple #5
0
  /**
   * Appends all elements of the supplied vector to this vector.
   *
   * @param toAppend the FastVector containing elements to append.
   */
  public final void appendElements(FastVector toAppend) {

    setCapacity(size() + toAppend.size());
    System.arraycopy(toAppend.m_Objects, 0, m_Objects, size(), toAppend.size());
    m_Size = m_Objects.length;
  }