Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

level_set.hh

Go to the documentation of this file.
00001 
00004 #ifndef __LEVEL_SET_HH__
00005 #define __LEVEL_SET_HH__
00006 
00007 #include <tab_label.hh>
00008 #include <tab_dart.hh>
00009 #include <dart.hh>
00010 #include <iostream>
00011 #include <fstream>
00012 using namespace std;
00013 
00014 class l_set_iteratorator_error
00015 {
00016 public:
00017   l_set_iteratorator_error(){}
00018   l_set_iteratorator_error(const char* messg)
00019   {
00020     cerr << messg<<endl;
00021   }
00022 };
00023 
00025 class level_set
00026 {
00027 protected:
00028   // Number of the last level of the level_set
00029   int max_level;
00030   // Number of darts stocked on the level_set, 2 times nb_edge
00031   int nb_dart;
00032   // Infinit array that hold for each level the first dart index of the level
00033   tab_label levels;
00034   // Array to store the darts index
00035   int *dart_index;
00036   // Array to store the darts
00037   dart *darts;
00038   // Array to store the level of each darts
00039   tab_dart dart_level;
00040 
00041 public:
00043   level_set(const level_set &);
00045   level_set(int);
00047   level_set():max_level(0), nb_dart(0), dart_index(NULL), darts(NULL)
00048   {}
00050   ~level_set();
00051 
00053   level_set & operator=(const level_set &);
00054 
00056   int load(ifstream &in);
00058   int save(ofstream &out);
00059   
00061   int give_max_level();
00063   void new_level();
00064 
00066   int give_level(dart);
00067   // Suppress one dart
00068   void suppress_dart(dart);
00069   
00070   typedef enum {first_dart,begin_dart,last_dart,end_dart} position;
00071   friend class iterator
00072   {
00073   protected:
00074     // current index of the iterator
00075     int current;
00076     level_set* obj;
00077     int level;
00078     
00079   public:
00080     iterator();
00081     iterator(level_set& l,int level,position pos=level_set::first_dart);
00082     iterator(const iterator &);
00083 
00084     dart & operator *();
00085 
00086     iterator & operator=(const iterator &);
00087     iterator & operator++();
00088     iterator & operator++(int);
00089 
00090     bool operator<(const iterator&) const;
00091     bool operator>(const iterator&) const;
00092     bool operator<=(const iterator&) const;
00093     bool operator>=(const iterator&)const;
00094     bool operator==(const iterator&) const;
00095     bool operator!=(const iterator&) const;
00096   };
00097   
00099   iterator & first(int);
00101   iterator & begin(int);
00103   iterator & end(int);
00105   iterator & last(int);
00106 
00107 private:
00108   // Compute the dart_level that give the level of each dart
00109   void compute_all_levels();
00110   void display();
00111 };
00112 
00113 typedef level_set::iterator dart_iterator;
00114 
00115 
00116 #endif // __LEVEL_SET_HH__

Generated on Tue Jun 24 14:58:24 2003 for Combinatorial Pyramids by doxygen1.2.18