Logo Search packages:      
Sourcecode: ragel version File versions

template<class T, class Resize>
void Vector< T, Resize >::insertDup ( long  pos,
const T &  item,
long  len 
) [inline]

Insert len copies of item at position pos.

Elements in the vector from pos onward are shifted len spaces to the right. The copy constructor is used to place the element into this vector. If pos is greater than the length of the vector then undefined behaviour results. If pos is negative then it is treated as an offset relative to the length of the vector.

Definition at line 581 of file vector.h.

References Table< T >::data, and Table< T >::tabLen.

      /* If we are given a negative position to insert at then
       * treat it as a position relative to the length. */
      if ( pos < 0 )
            pos = BaseTable::tabLen + pos;
      /* Calculate the new length. */
      long newLen = BaseTable::tabLen + len;

      /* Up resize, we are growing. */
      upResize( newLen );

      /* Shift over data at insert spot if needed. */
      if ( len > 0 && pos < BaseTable::tabLen ) {
            memmove(BaseTable::data + pos + len, BaseTable::data + pos,

      /* Copy the data item in one at a time. */
      T *dst = BaseTable::data + pos;
      for ( long i = 0; i < len; i++, dst++ )
            new(dst) T(item);

      /* Set the new length. */
      BaseTable::tabLen = newLen;

Generated by  Doxygen 1.6.0   Back to index