00001
00002 #ifndef INCLUDED_IDEP_BINREL
00003 #define INCLUDED_IDEP_BINREL
00004
00005
00006
00007
00008 #include <iosfwd>
00009
00010 class idep_BinRel {
00011 char **d_rel_p;
00012 int d_size;
00013 int d_length;
00014
00015 private:
00016 void grow();
00017
00018
00019 void compress();
00020
00021
00022 void warshall(int bit);
00023
00024
00025 public:
00026
00027 idep_BinRel(int initialEntries = 0, int maxEntriesHint = 0);
00028
00029
00030
00031
00032
00033
00034 idep_BinRel(const idep_BinRel& rel);
00035 ~idep_BinRel();
00036
00037
00038 idep_BinRel& operator=(const idep_BinRel& rel);
00039
00040 void set(int row, int col, int bit);
00041
00042
00043
00044 void set(int row, int col);
00045
00046
00047 void clr(int row, int col);
00048
00049
00050 void makeTransitive();
00051
00052
00053
00054 void makeNonTransitive();
00055
00056
00057
00058
00059
00060
00061 int appendEntry();
00062
00063
00064
00065
00066 int get(int row, int col) const;
00067
00068
00069 int cmp(const idep_BinRel& rel) const;
00070
00071
00072
00073 int length() const;
00074
00075
00076
00077 };
00078
00079 std::ostream& operator<<(std::ostream& out, const idep_BinRel& rel);
00080
00081
00082
00083 int operator==(const idep_BinRel& left, const idep_BinRel& right);
00084
00085
00086 int operator!=(const idep_BinRel& left, const idep_BinRel& right);
00087
00088
00089
00090
00091
00092
00093
00094 inline
00095 int idep_BinRel::appendEntry()
00096 {
00097 if (d_length >= d_size) {
00098 grow();
00099 }
00100 return d_length++;
00101 }
00102
00103 inline
00104 void idep_BinRel::set(int row, int col, int bit)
00105 {
00106 d_rel_p[row][col] = !!bit;
00107 }
00108
00109 inline
00110 void idep_BinRel::set(int row, int col)
00111 {
00112 d_rel_p[row][col] = 1;
00113 }
00114
00115 inline
00116 void idep_BinRel::clr(int row, int col)
00117 {
00118 d_rel_p[row][col] = 0;
00119 }
00120
00121 inline
00122 int idep_BinRel::get(int row, int col) const
00123 {
00124 return d_rel_p[row][col];
00125 }
00126
00127 inline
00128 int idep_BinRel::length() const
00129 {
00130 return d_length;
00131 }
00132
00133 inline
00134 int operator==(const idep_BinRel& left, const idep_BinRel& right)
00135 {
00136 return left.cmp(right) == 0;
00137 }
00138
00139 inline
00140 int operator!=(const idep_BinRel& left, const idep_BinRel& right)
00141 {
00142 return left.cmp(right) != 0;
00143 }
00144
00145 #endif
00146