#ifndef DYNSTRINGARRAY_H #define DYNSTRINGARRAY_H //***************************************************************************** // // DynSTringArray.h // //***************************************************************************** // // Copyright (C) 1996 // // Ronald A. MacCracken // Graduate Student // Computer Science Department // University of California // Davis, CA 95616 // // Permission is granted to use at your own risk and // distribute this software in source and binary forms // provided the above copyright notice and this paragraph // are preserved on all copies. This software is provided // "as is" with no express or implied warranty. // //***************************************************************************** #include #include "STring.h" class DynSTringArray { private: int _chunk ; int _allocated ; int _length ; STring* _array ; private: void Copy ( const DynSTringArray& ) ; void Delete ( void ) ; protected: void Output ( ostream& ) const ; void Input ( istream& ) ; public: // default constructor DynSTringArray ( void ) ; // user-defined constructors DynSTringArray ( const int& chunk ) ; DynSTringArray ( const int& length , const STring& data , const int& chunk = 10 ) ; DynSTringArray ( const int& length , const STring* new_array , const int& chunk = 10 ) ; // copy constructor DynSTringArray ( const DynSTringArray& ) ; // destructor ~DynSTringArray ( void ) ; // assignment operators DynSTringArray& operator= ( const DynSTringArray& ) ; // index operators STring& operator[] ( const int& i ) ; const STring& operator[] ( const int& i ) const ; // access functions int Get_Length ( void ) const { return _length ; } // add element or array void Add ( const STring& data ) ; void Add ( const DynSTringArray& a ) ; // remove element i from array void Remove ( const int& i ) ; // set all elements to data void Set_All ( const STring& data ) ; // swap element i with element j void Swap ( const int& i , const int& j ) ; // I/O operators friend ostream& operator<< ( ostream& , const DynSTringArray& ) ; friend istream& operator>> ( istream& , DynSTringArray& ) ; } ; #endif