ht_accum.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __FIREVISION_HT_ACCUM_H_
00025 #define __FIREVISION_HT_ACCUM_H_
00026
00027 #include <stdlib.h>
00028 #include <ostream>
00029 #include <vector>
00030
00031 class RhtAccNode
00032 {
00033 public:
00034 RhtAccNode();
00035 virtual ~RhtAccNode();
00036 virtual void clear(int ignore);
00037
00038 protected:
00039
00040 RhtAccNode* left;
00041
00042 RhtAccNode* right;
00043
00044 RhtAccNode* next;
00045 };
00046
00047 class RhtRNode : public RhtAccNode
00048 {
00049 public:
00050 RhtRNode(int r);
00051 void clear(void);
00052 int insert(int r);
00053 void dump(std::ostream&, int x, int y);
00054 void clear(int r);
00055 void getNodes(std::vector< std::vector< int > > *rv, int min_votes, int x, int y);
00056
00057 static RhtRNode* generate(int r);
00058 static void reset(void);
00059 static void cleanup(void);
00060
00061 protected:
00062
00063 int r;
00064
00065 int count;
00066
00067 private:
00068 static RhtRNode* reuse_head;
00069 static RhtRNode* reuse_tail;
00070 };
00071
00072 class RhtYNode : public RhtAccNode
00073 {
00074 private:
00075 static RhtYNode* reuse_head;
00076 static RhtYNode* reuse_tail;
00077 public:
00078 static RhtYNode* generate(int y);
00079 static void reset(void);
00080 static void cleanup(void);
00081
00082 protected:
00083
00084 int y;
00085
00086 RhtRNode* r_root;
00087
00088 public:
00089 RhtYNode(int y);
00090 int insert(int y, int r);
00091 void dump(std::ostream&, int x);
00092 void clear(int y);
00093 void getNodes(std::vector< std::vector< int > > *rv, int min_votes, int x);
00094 };
00095
00096 class RhtXNode : public RhtAccNode
00097 {
00098 private:
00099 static RhtXNode* reuse_head;
00100 static RhtXNode* reuse_tail;
00101 public:
00102 static RhtXNode* generate(int x);
00103 static void reset(void);
00104 static void cleanup(void);
00105
00106 protected:
00107
00108 int x;
00109
00110 RhtYNode* y_root;
00111
00112 public:
00113 RhtXNode(int x);
00114 int insert(int x, int y, int r);
00115 void dump(std::ostream&);
00116 void clear (int x);
00117 void getNodes(std::vector< std::vector< int > > *rv, int min_votes);
00118 };
00119
00120 class RhtAccumulator
00121 {
00122 private:
00123 int x_max;
00124 int y_max;
00125 int r_max;
00126 int max;
00127
00128 RhtXNode* root;
00129
00130 int num_votes;
00131
00132 public:
00133 RhtAccumulator();
00134 ~RhtAccumulator();
00135 int accumulate(int x, int y, int r);
00136 int getMax(int& x, int& y, int& r) const;
00137 void dump(std::ostream&);
00138 void reset(void);
00139 unsigned int getNumVotes() const;
00140 std::vector< std::vector< int > > * getNodes(int min_count);
00141 };
00142
00143 #endif // __FIREVISION_HT_ACCUM_H_
00144