// ========================================================================== // Declaration for a string array with random selection // A. Fischer, May 13, 2001 file: rstrings.hpp // Modified by M. Fischer, October 8, 2009 // ========================================================================== #pragma once #include "tools.hpp" #include "flexT.hpp" #include "sstore.hpp" //=========================================================================== class RandString : FlexArray { protected: StringStore store; // Storage behind string array. private: inline const_cstring remove( int r ); void print( ostream& outs ) const; // For debugging, make this public. public: RandString( istream& vocin, int sz = 100 ); ~RandString() {} inline void put(const_cstring s, int len); const_cstring randword(); }; //--------------------------------------------------------------------------- inline const_cstring RandString::remove( int r ) { const_cstring ret = data[r]; // Grab the word that was selected. data[r] = data[--n]; // Replace by last word in array. data[n] = ret; return ret; // Return word and decrease word count. } //--------------------------------------------------------------------------- inline void RandString::put(const_cstring s, int len) { FlexArray::put(store.put(s, len)); }