dddd
April 22nd, 2009
//---------------------------------------------------------------------------- //! TSArray.h //! //! Author: Yuge Zhou SUID: 973916484 //! //! @file //! //! @brief This file defines the Class TSArray. //! //! This class provides a basic function to implement the three-dimensioned array. //! This single-dimensioned array can accece the element use three index in each dimension. //! and user can also chang the size of the array according to user's wishes. //! user can use &lt;&lt; and &gt;&gt; to add the data of the array easily. //! //! This class use the NodeSLList.h and IntNode.h //! to help implement the function //---------------------------------------------------------------------------- #ifndef _H_TSARRAY_ #define _H_TSARRAY_ #include&quot;NodeSLList.h&quot; #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 &lt;&lt; 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 &amp;operator&lt;&lt;(ostream&amp; output, const TSArray &amp; tsarray); //---------------------------------------------------------------------------- //! @brief Define the &gt;&gt; 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 &amp;operator&gt;&gt;(istream&amp; input , TSArray &amp; 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 &amp;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 &amp; operator=(const TSArray &amp;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 &amp;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 &amp;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
