Logo Search packages:      
Sourcecode: ragel version File versions

template<class T, class Resize>
Vector< T, Resize >::Vector ( long  size,
long  allocLen 
) [inline]

Create a vector with a specified number of initial elements and allocation.

Default constructors are used to create the new elements. If the size is greater than allocLen, then the space will be grown according to the allocation scheme. Both size and allocLen are in units of T. If a linear resizer is used, the step defaults to 256 units of T. For a runtime vector both up and down allocation schemes default to Exponential.

Definition at line 307 of file vectcommon.h.

References Table< T >::allocLen, Table< T >::data, and Vector< T, Resize >::setAsNew().

{
      /* Allocate the space if we are given a positive allocLen. */
      BaseTable::allocLen = allocLen;
      if ( allocLen > 0 ) {
            BaseTable::data = (T*) malloc(sizeof(T) * BaseTable::allocLen);
            if ( BaseTable::data == 0 )
                  throw std::bad_alloc();
      }

      /* Grow to the size specified. If we did not have enough space
       * allocated that is ok. Table will be grown to right size. */
      setAsNew( size );
}


Generated by  Doxygen 1.6.0   Back to index