/** * 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; }
/** * 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; }
/** * 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; }
// @ 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; }
/** * 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; }