April 22nd, 2009

#ifndef _H_TSARRAY_
#define _H_TSARRAY_

#include"NodeSLList.h"

#include <iostream>
using std::ostream ;
using std::istream;

//---------------------------------------------------------------------------
//! @brief  This class provides a basic function to implement the Three-dimensioned array..
//---------------------------------------------------------------------------
class TSArray
{
    //----------------------------------------------------------------------------
    //! @brief Define the << operator the help output the detail of the array
    //!
    //! @param output  the output ostream;
    //! @param tsarray the TSArray object which need to be outputed
    //! @return The ostream
    //----------------------------------------------------------------------------
    friend ostream &operator<<(ostream& output, const TSArray & tsarray);

    //----------------------------------------------------------------------------
    //! @brief Define the >> operator the help input the data of the array
    //!
    //! @param input  the input ostream;
    //! @param tsarray the TSArray object which need to be inputed
    //! @return The istream
    //----------------------------------------------------------------------------
    friend istream &operator>>(istream& input ,  TSArray & tsarray);

public:
    //----------------------------------------------------------------------------
    //! @brief Constructor : Creates the Board object.
    //!
    //! @param rows The number of rows of the Three-dimensioned array
    //! @param columns The number of rocolumnsws of the Three-dimensioned array
    //! @param depth The number of depth of the Three-dimensioned array
    //----------------------------------------------------------------------------
    TSArray(int rows=0, int columns=0, int depth=0);

    //----------------------------------------------------------------------------
    //! @brief Destructor: deletes TSArray object.
    //----------------------------------------------------------------------------
    ~TSArray();

    //----------------------------------------------------------------------------
    //! @brief Define the () operator the get data of element the array
    //!
    //! @param row The number of the row of the Three-dimensioned array
    //! @param column The number of the columnsws of the Three-dimensioned array
    //! @param depth The number of the depth of the Three-dimensioned array
    //!
    //! @return The value of the array element
    //----------------------------------------------------------------------------
    int operator()( int row=1, int column=1, int depth=1) const;

    //----------------------------------------------------------------------------
    //! @brief Define the () operator the get data of element the array
    //!
    //! @param row The number of the row of the Three-dimensioned array
    //! @param column The number of the columnsws of the Three-dimensioned array
    //! @param depth The number of the depth of the Three-dimensioned array
    //!
    //! @return The reference of the array element
    //----------------------------------------------------------------------------
    int &operator()( int row=1, int column=1, int depth=1);

    //----------------------------------------------------------------------------
    //! @brief Define the = operator the refined the assignment function
    //!
    //! @param right The TSArray object need to be assigned.
    //!
    //! @return The reference of left object
    //----------------------------------------------------------------------------
    const TSArray & operator=(const TSArray &right );

    //----------------------------------------------------------------------------
    //! @brief Define the == operator to compare the TSArray object
    //!
    //! @param right The TSArray object need to be compared.
    //!
    //! @return equality – always return FALSE for different-sized arrays
    //----------------------------------------------------------------------------
    bool operator==( const TSArray &right) const;

    //----------------------------------------------------------------------------
    //! @brief Define the != operator to compare the TSArray object
    //!
    //! @param right The TSArray object need to be compared.
    //!
    //! @return inequality – always return TRUE for different-sized arrays
    //----------------------------------------------------------------------------
    bool operator!=( const TSArray &right) const
    {
        return ! ( *this == right ); // invokes Array::operator==
    }

    //----------------------------------------------------------------------------
    //! @brief This will dynamically change the size of the array in any or all dimensions.
    //!     When the array is made larger in any dimension, existing elements will not be
    //!     affected. When the array is made smaller in any dimension, existing elements
    //!     will be truncated (pruned) in that dimension.
    //!
    //! @param row The number of the row of the Three-dimensioned array
    //! @param column The number of the columnsws of the Three-dimensioned array
    //! @param depth The number of the depth of the Three-dimensioned array
    //----------------------------------------------------------------------------
    void ChangeSize(int row, int column, int depth);

private:

    //Record the size of the three-dimensioned array
    int rowsMax, columnsMax, depthMax, init;

    //The data container
    NodeSLList *ns; 

};

#endif
Author: tanker Categories: Uncategorized Tags:
  1. April 22nd, 2009 at 09:48 | #1

    xcn

  1. No trackbacks yet.