/*
 * Copyright 1995, 1996 Perforce Software.  All rights reserved.
 */

/*
 * strarray.h - 0 based arrays of StrBufs, StrPtrs
 *
 * Class Defined:
 *
 *	StrArray - a linear list of StrBufs
 *	StrPtrArray - a linear list of StrPtrs
 *
 * Public methods:
 *
 * Private methods:
 */

class StrVarArray;

class StrArray {
	
    public:

			StrArray();
			StrArray( int max );
			~StrArray();

	StrBuf *	Put();
	const StrBuf *	Get(int i) const;
	StrBuf *	Edit(int i);
	int		Count() const ;
	void		Clear();
	void		Sort( int caseFolding );
	void		Remove( int i );
	int		Search( const StrBuf *key );
	const StrBuf *	Find( const StrBuf *key );
	int		GetIndex( const StrBuf *key );
	void		Copy( const StrArray *other );

    private:

	StrVarArray	*array;
} ;

class StrPtrArray {

    public:
			StrPtrArray();
			StrPtrArray( int size );
			~StrPtrArray();

	bool		Put( const StrPtr &val );
	const StrPtr *	Get( int i ) const { return &tabVal[i]; }
	void		Clear() { tabLength = 0; }
	int		Count() const { return tabLength; }
	StrPtr *	Table() const { return tabVal; }

    private:
	bool		Extend( int newSize );

	// our own VarArray-like implementation
	
	StrRef		*tabVal;	
	int		tabSize;
	int		tabLength;

} ;

