Grafalgo
Library of useful data structures and algorithms
/Users/jst/src/grafalgo/cpp/include/ClistSet.h
Go to the documentation of this file.
00001 
00009 #ifndef CLISTSET_H
00010 #define CLISTSET_H
00011 
00012 #include "stdinc.h"
00013 #include "Adt.h"
00014 
00015 namespace grafalgo {
00016 
00022 class ClistSet : public Adt {
00023 public:         ClistSet(int);
00024                 ~ClistSet();
00025 
00026         // common methods
00027         void    clear();
00028         void    resize(int);
00029         void    expand(int);
00030         void    copyFrom(const ClistSet&);
00031 
00032         // list traversal methods
00033         int     suc(index) const;
00034         int     pred(index) const;
00035 
00036         // modifiers
00037         void    join(index,index);
00038         void    remove(index);
00039 
00040         string& toString(string&) const;
00041 private:
00042         struct lnode {
00043         int     next;                   // index of successor
00044         int     prev;                   // index of predecessor
00045         } *node;
00046 
00047         void    makeSpace(int);
00048         void    freeSpace();
00049 };
00050 
00055 inline index ClistSet::suc(index i) const {
00056         assert(0 <= i && i <= n()); return node[i].next;
00057 }
00058 
00063 inline index ClistSet::pred(index i) const {
00064         assert(0 <= i && i <= n()); return node[i].prev;
00065 }
00066 
00067 } // ends namespace
00068 
00069 #endif
 All Classes Files Functions Variables Typedefs Friends