Grafalgo
Library of useful data structures and algorithms
/Users/jst/src/grafalgo/cpp/include/Adt.h
Go to the documentation of this file.
00001 
00009 #ifndef ADT_H
00010 #define ADT_H
00011 
00012 #include "stdinc.h"
00013 #include "Exceptions.h"
00014 #include "Util.h"
00015 
00016 using namespace std;
00017 
00018 using std::string;
00019 
00020 namespace grafalgo {
00021 
00022 // these are just handy names for indicating the usage of arguments
00023 typedef int32_t index;
00024 typedef int32_t position;
00025 
00046 class Adt {
00047 public:
00048         static const int32_t MAXINDEX = 0x7ffffff;
00049         static const int32_t MAXPOSITION = 0x7ffffff;
00050 
00051         Adt(index size=26) : nn(size) {}
00052         virtual ~Adt() {}
00053 
00054         index n() const { return nn; }
00055 
00056         // disallow copy constructors, assignments
00057         Adt(const Adt&) = delete;
00058         Adt& operator=(const Adt&) = delete;
00059         Adt& operator=( Adt&&) = delete;
00060 
00061         // derived classes must provide these methods
00062         virtual void clear() = 0;
00063         virtual void resize(int size) = 0;
00064         virtual void expand(int size) = 0;
00065 
00066         // input/output
00067         static bool readItem(istream&, index&);
00068         virtual string& item2string(index, string&) const;
00069         virtual string& toString(string&) const = 0;
00070         friend ostream& operator<<(ostream& out, Adt& a) {
00071                 string s; return out << a.toString(s);
00072         }
00073 
00074 protected:
00075         index   nn;     
00076 };
00077 
00078 } // ends namespace
00079 
00080 #endif
 All Classes Files Functions Variables Typedefs Friends