00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_FRAME_FILTER_FAST_INTERSECTOR_HH_
00023 # define WIFI_FRAME_FILTER_FAST_INTERSECTOR_HH_
00024
00025 # include <utility>
00026
00027 # include <wipal/tool/hash.hh>
00028 # include <wipal/tool/valued_iterator.hh>
00029 # include <wipal/tool/microseconds.hh>
00030 # include <wipal/tool/iterable.hh>
00031 # include <wipal/wifi/addr_mapping.hh>
00032
00033 # include "fast_intersector_fwd.hh"
00034
00035 namespace tool
00036 {
00037
00038 template <class I1, class I2, class B1, class B2>
00039 struct types< wifi::frame::filter::internals::
00040 fast_intersector_iterator<I1, I2, B1, B2> >
00041 {
00042 typedef
00043 std::pair<typename I1::value_type, typename I2::value_type>
00044 value_type;
00045
00046 typedef
00047 wifi::frame::filter::fast_intersector<I1, I2, B1>
00048 iterable_type;
00049 };
00050
00051 template <class I1, class I2, class B>
00052 struct types< wifi::frame::filter::fast_intersector<I1, I2, B> >
00053 {
00054 typedef wifi::frame::filter::internals::
00055 fast_intersector_iterator<I1, I2, B, bottom>
00056 iterator;
00057 };
00058
00059 }
00060
00061 namespace wifi
00062 {
00063 namespace frame
00064 {
00065 namespace filter
00066 {
00067
00068 namespace internals
00069 {
00070 template <class I1, class I2, class B, class Bottom = tool::bottom>
00071 struct fast_intersector_iterator:
00072 WP_INHERIT(public tool::valued_iterator,
00073 fast_intersector_iterator<I1, I2, B, Bottom>)
00074 {
00075
00077
00078 typedef WP_GET_EXACT(Bottom,
00079 fast_intersector_iterator<I1, I2, B, Bottom>)
00080 exact_type;
00081 typedef tool::valued_iterator<exact_type> super_type;
00082 typedef WP_TYPE(value_type, exact_type) value_type;
00083 typedef WP_TYPE(iterable_type, exact_type) iterable_type;
00085
00087 fast_intersector_iterator(const iterable_type& i, bool end);
00088
00090
00091 bool equal(const fast_intersector_iterator& rhs) const;
00092 void increment();
00094
00095 private:
00096 enum
00097 {
00105 dt_warn_threshold = 15 * 60 * 1000 * 1000,
00106
00113 drift_warn_threshold = 10 * 1000 * 1000
00114 };
00115
00116 bool check();
00117
00118 const iterable_type* iterable_;
00119 I2 next_;
00120
00121
00122
00123
00124 typename super_type::optional_value lookahead_;
00125
00126 # ifdef WP_ENABLE_INFO
00127 unsigned rhs_total_;
00128 unsigned ref_total_;
00129 # endif // WP_ENABLE_INFO
00130 };
00131
00132 }
00133
00134
00135 template <class InputIterator1,
00136 class InputIterator2,
00137 class Bottom = tool::bottom>
00138 struct fast_intersector:
00139 WP_INHERIT(public tool::iterable, fast_intersector<InputIterator1,
00140 InputIterator2,
00141 Bottom>)
00142 {
00143 fast_intersector(const InputIterator1& first1,
00144 const InputIterator1& last1,
00145 const InputIterator2& first2,
00146 const InputIterator2& last2);
00147
00148 # ifdef WP_DONT_USE_HASH
00149 typedef std::set<typename InputIterator1::value_type> arrivals_type;
00150 # else
00151 typedef
00152 tool::hash_set<typename InputIterator1::value_type> arrivals_type;
00153
00154 enum
00155 {
00165 hash_bucket_count = 1 << 25
00166 };
00167 # endif
00168
00169 private:
00170 InputIterator2 first_;
00171 InputIterator2 last_;
00172 arrivals_type arrivals_;
00173
00174 friend
00175 class internals::fast_intersector_iterator<InputIterator1,
00176 InputIterator2,
00177 Bottom,
00178 tool::bottom>;
00179 };
00180
00181 }
00182
00183 }
00184
00185 }
00186
00187 # include "fast_intersector.hxx"
00188
00189 #endif