Main Page   Class Hierarchy   Compound List   Header Files   Compound Members  

bgcontainer.h

This is the verbatim text of the bgcontainer.h include file.
#ifndef __BGCONTAINER_H__
#define __BGCONTAINER_H__

/* $Id: bgcontainer.h,v 1.1 2000/02/18 09:04:17 dpfeifle Exp $ */

#define REALLOCSIZE     32

#include "bgobject.h"

// ------------------------------------------------------------------
// Class: BGContainer
// ------------------------------------------------------------------

class BGContainer
   : public BGObject
{
};

// ------------------------------------------------------------------
// Class: BGEnumeratable
// ------------------------------------------------------------------

class BGEnumeratable
{
public:

virtual long
   length                    ( ) const = 0;

virtual BGObject*
   get                       ( long position ) = 0;
};

// ------------------------------------------------------------------
// Class: BGEnumeration
// ------------------------------------------------------------------

class BGEnumeration
{
public:

   BGEnumeration             ( BGEnumeratable *src ) { source=src; pos=0; }

virtual bool
   hasMoreElements           ( ) { return (pos<source->length()) ? true : false; }

virtual BGObject*
   nextElement               ( ) { return source->get(pos++); }

private:
BGEnumeratable
   *source;
long
   pos;
};

// ------------------------------------------------------------------
// Class: BGArray
// ------------------------------------------------------------------

class BGArray
   : public BGContainer,
     public BGEnumeratable
{
public:

   BGArray                   ( );

   BGArray                   ( long initialSize );

virtual
   ~BGArray                  ( );

virtual BGString
   toString                  ( );
virtual unsigned long
   hash                      ( );
virtual int
   compare                   ( BGObject &obj );
virtual bool
   equals                    ( BGObject &obj );
virtual BGString
   className                 ( );
long
   length                    ( ) const ;

void
   ensure                    ( long neededSize );

BGArray&
   add                       ( BGObject *newObject );

BGArray&
   set                       ( BGObject *newObject, long i );

BGObject*
   get                       ( long i );

protected:

void
   realloc                   ( long plusSize = REALLOCSIZE );

private:

BGObject**
   buf;
long
   len;
size_t
   allocsize;
};
inline long  BGArray :: length() const { return len; }

class BGHashtable
   : public BGContainer,
     public BGEnumeratable
{
public:
   BGHashtable               ( );
virtual
  ~BGHashtable               ( );

virtual BGString
   toString                  ( );
virtual unsigned long
   hash                      ( );
virtual int
   compare                   ( BGObject &obj );
virtual BGString
   className                 ( );
virtual bool
   equals                    ( BGObject &obj );

BGObject*
   get                       ( BGObject &key );

void
   put                       ( BGObject &key, BGObject *newObject );

virtual long
   length                    ( ) const { return 0; };

virtual BGObject*
   get                       ( long position ) { return 0; };

};

#endif


Generated at Fri Feb 18 10:57:06 2000 for bgclass by doxygen 0.49-991205 written by Dimitri van Heesch, © 1997-1999