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 ];
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;
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];
Definition of class SequenceHeaderByteIO.
Definition: accessunit_byteio.h:52
std::ostream & operator<<(std::ostream &stream, TwoDArray< T > &array)
A function for extracting array data.
Definition: arrays.h:565
std::istream & operator>>(std::istream &stream, TwoDArray< T > &array)
A function for inserting array data.
Definition: arrays.h:581
Range type.
Definition: arrays.h:61
int First() const
Returns the start of the range.
Definition: arrays.h:70
Range(int s, int e)
Constructor.
Definition: arrays.h:67
int m_lst
Definition: arrays.h:76
int m_fst
Definition: arrays.h:76
int Last() const
Returns the end point of the range.
Definition: arrays.h:73
A template class for one-dimensional arrays.
Definition: arrays.h:90
~OneDArray()
Destructor.
Definition: arrays.h:116
OneDArray< T > & operator=(const OneDArray< T > &rhs)
Assignment=.
Definition: arrays.h:200
void FreePtr()
Definition: arrays.h:264
void Init(const Range &r)
Definition: arrays.h:243
int m_first
Definition: arrays.h:158
const T & operator[](const int pos) const
Element access.
Definition: arrays.h:140
OneDArray(const int len)
'Length' constructor.
Definition: arrays.h:173
int m_last
Definition: arrays.h:158
OneDArray(const OneDArray< T > &cpy)
Copy constructor.
Definition: arrays.h:185
int m_length
Definition: arrays.h:159
int Length() const
Returns the length of the array.
Definition: arrays.h:143
int First() const
Returns the index of the first element.
Definition: arrays.h:146
void Resize(int l)
Resize the array, throwing away the current data.
Definition: arrays.h:221
T * m_ptr
Definition: arrays.h:160
OneDArray(const Range &r)
Range constructor.
Definition: arrays.h:179
int Last() const
Returns the index of the last element.
Definition: arrays.h:149
void Init(const int len)
Definition: arrays.h:234
T & operator[](const int pos)
Element access.
Definition: arrays.h:137
OneDArray()
Default constructor.
Definition: arrays.h:167
A template class for two-dimensional arrays.
Definition: arrays.h:285
bool CopyContents(TwoDArray< T > &out) const
Copy Contents.
Definition: arrays.h:461
int LengthX() const
Returns the width.
Definition: arrays.h:362
int LastX() const
Returns the index of the last element of a row.
Definition: arrays.h:374
TwoDArray(const int height, const int width)
Constructor.
Definition: arrays.h:300
TwoDArray()
Default constructor.
Definition: arrays.h:294
TwoDArray< T > & operator=(const TwoDArray< T > &rhs)
Assignment =.
Definition: arrays.h:430
int LastY() const
Returns the index of the first element of a column.
Definition: arrays.h:377
void Fill(T val)
Fill contents.
Definition: arrays.h:482
int m_first_x
Definition: arrays.h:386
int m_length_x
Definition: arrays.h:392
int FirstX() const
Returns the index of the first element of a row.
Definition: arrays.h:368
element_type & operator[](const int pos)
Element access.
Definition: arrays.h:352
virtual ~TwoDArray()
Destructor.
Definition: arrays.h:313
void FreeData()
Free all the allocated data.
Definition: arrays.h:546
const element_type & operator[](const int pos) const
Element access.
Definition: arrays.h:359
int LengthY() const
Returns the height.
Definition: arrays.h:365
element_type * m_array_of_rows
Definition: arrays.h:395
void Resize(const int height, const int width)
Resizes the array, deleting the current data.
Definition: arrays.h:489
int m_last_x
Definition: arrays.h:389
void Init(const int height, const int width)
Initialise the array.
Definition: arrays.h:502
int m_first_y
Definition: arrays.h:387
T * element_type
Definition: arrays.h:286
TwoDArray(const TwoDArray< T > &Cpy)
Copy constructor.
Definition: arrays.h:409
int FirstY() const
Returns the index of the first element of a column.
Definition: arrays.h:371
int m_length_y
Definition: arrays.h:393
TwoDArray(const int height, const int width, T val)
Constructor.
Definition: arrays.h:402
int m_last_y
Definition: arrays.h:390