Many lists/collections of objects are required. To ease development a general purpose list of pointers is available.
The base class for such a feature is,
class GenericFeature
{
public:
virtual ~GenericFeature() {};
};
ASIDE --- note penalty of size by making this virtual --- do we care ?
And a feature list is
class FeatureList {
public:
friend class FeatureListIterator;
FeatureList( int clustSize = 10 );
virtual ~FeatureList();
BOOL add(GenericFeature *fea, const BOOL check = TRUE );
BOOL remove( const GenericFeature *fea );
void clear();
BOOL contains( const GenericFeature *fea ) const;
GenericFeature * first() const;
GenericFeature * operator[](int index) const;
int numElements() const;
private:
GenericFeature** _features;
FeatureList * _next;
int _numElems;
int _clusterSize;
};
ASIDE ( I would like to see some of the above members protected - pjl )
A GoString is derived from a GenericFeature this allows
class StringCollection : public FeatureList
{
public:
StringCollection( int clustSize = 10 ) : FeatureList(clustSize) {}
GoString * first() const { return (GoString *)FeatureList::first(); }
GoString * operator[](int index) const
{
return (GoString *)FeatureList::operator[](index);
}
};