152 void Init(
const int len);
189 m_length = m_last - m_first + 1;
194 Init(
Range(m_first , m_last));
196 memcpy( m_ptr , cpy.
m_ptr , m_length *
sizeof( T ) );
212 Init(
Range(m_first , m_last));
214 memcpy( m_ptr , rhs.
m_ptr , m_length *
sizeof( T ) );
248 m_length = m_last - m_first + 1;
252 m_ptr =
new T[ m_length ];
307 TwoDArray(
const int height ,
const int width , T val);
345 void Resize(
const int height,
const int width);
381 void Init(
const int height,
const int width);
404 Init( height , width );
405 std::fill_n( m_array_of_rows[0], m_length_x*m_length_y, val);
416 m_length_x = m_last_x - m_first_x + 1;
417 m_length_y = m_last_y - m_first_y + 1;
419 if (m_first_x == 0 && m_first_y == 0)
420 Init(m_length_y , m_length_x);
425 memcpy( m_array_of_rows[0] , (Cpy.
m_array_of_rows)[0] , m_length_x * m_length_y *
sizeof( T ) );
442 m_length_x = m_last_x - m_first_x + 1;
443 m_length_y = m_last_y - m_first_y + 1;
445 if (m_first_x == 0 && m_first_y == 0)
446 Init(m_length_y , m_length_x);
452 memcpy( m_array_of_rows[0], (rhs.
m_array_of_rows)[0], m_length_x * m_length_y *
sizeof( T ) );
465 int rows = std::min (m_length_y, out.
m_length_y);
466 int cols = std::min (m_length_x, out.
m_length_x);
467 for (
int j = 0; j < rows; ++j)
469 memcpy( out.
m_array_of_rows[j], m_array_of_rows[j], cols *
sizeof( T )) ;
484 if (m_length_x && m_length_y)
485 std::fill_n( m_array_of_rows[0], m_length_x*m_length_y, val);
491 if (height != m_length_y || width != m_length_x)
494 Init(height , width);
509 m_last_x = m_length_x-1;
510 m_last_y = m_length_y-1;
520 m_array_of_rows[0] =
new T[ m_length_x * m_length_y ];
523 for (
int j=1 ; j<m_length_y ; ++j)
524 m_array_of_rows[j] = m_array_of_rows[0] + j * m_length_x;
541 m_array_of_rows = NULL;
552 delete[] m_array_of_rows[0];
555 m_length_y = m_length_x = 0;
557 delete[] m_array_of_rows;
565 std::ostream & operator<< (std::ostream & stream, TwoDArray<T> & array)
567 for (
int j=0 ; j<array.LengthY() ; ++j)
569 for (
int i=0 ; i<array.LengthX() ; ++i)
571 stream << array[j][i] <<
" ";
583 for (
int j=0 ; j<array.
LengthY() ; ++j)
585 for (
int i=0 ; i<array.
LengthX() ; ++i)
587 stream >> array[j][i];