#ifndef DUMBCONTAINER_HH
#define DUMBCONTAINER_HH

/*
 * CS70, Spring 2001
 *
 * Interface definition for a very simple container class.  This class
 * allows the user to put stuff in and get it back out, not
 * necessarily in the same order.  An iterator is also provided, so
 * that the container contents can be examined nondestructively.
 */

/*
 * The definition of the string class is complicated (it's not just
 * "class string"), so it's safer to #include the class header file so
 * that we can use "string" as a type.
 */
#include <string>

/*
 * Classes defined in this file:
 */
class DumbContainer;
class DumbContainerIterator;

/*
 * Trivial container class.  The container size must be specified when
 * the container is created, and it can never change.  Only strings
 * can be stored in it.
 */
class DumbContainer
    {
	friend		DumbContainerIterator;

    public:
			DumbContainer(unsigned int maxSize_ = 100);
			~DumbContainer();
	bool		add(const string& info);
					// Add a string to the container
					// ..returns false if add failed
	string		remove();	// Remove and return a string.  The
					// ..order of removal is undefined.
	bool		isEmpty() const;
					// Test whether container has stuff
    private:
	/*
	 * Disable copy and assignment
	 */
			DumbContainer(const DumbContainer& source);
	DumbContainer&	operator=(const DumbContainer& source);

	/*
	 * Private data
	 */
	unsigned int	maxSize;	// Maximum size of the container
	unsigned int	currentSize;	// Current size of the container
	string*		strings;	// Space to store the strings
    };

/*
 * Iterator for the dumb container class.  This iterator allows the
 * user to access the container contents without emptying it.  The
 * order of access is undefined.
 */
class DumbContainerIterator
    {
    public:
			DumbContainerIterator(const DumbContainer& target_);
			DumbContainerIterator(
			  const DumbContainerIterator& source);
			~DumbContainerIterator();

	/*
	 * Standard operators
	 */
	DumbContainerIterator&
			operator=(const DumbContainerIterator& source);

	/*
	 * Overloaded iterator operators
	 */
			operator bool() const;
					// Return true if more data left
	DumbContainerIterator&
			operator++();	// Preincrement the iterator
	DumbContainerIterator
			operator++(int);
					// Postincrement the iterator
	string&		operator*() const;
					// Return current string
	string*		operator->() const;
					// Return current string

    private:
	const DumbContainer*
			target;		// Container we're iterating over
	unsigned int	position;	// Where we are in the container
    };

#endif // DUMBCONTAINER_HH
