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_OLD_INTERSECTOR_HH_
00023 # define WIFI_FRAME_FILTER_OLD_INTERSECTOR_HH_
00024
00025 # include <utility>
00026
00027 # include <wipal/tool/iterable.hh>
00028 # include <wipal/tool/hash.hh>
00029 # include <wipal/tool/valued_iterator.hh>
00030 # include <wipal/tool/microseconds.hh>
00031
00032 # include "old_intersector_fwd.hh"
00033
00034
00035 namespace tool
00036 {
00037
00038 template <class I1, class I2, class B1, class B2>
00039 struct types< wifi::frame::filter::internals::
00040 old_intersector_iterator<I1, I2, B1, B2> >
00041 {
00042 typedef std::pair<typename I1::value_type, typename I2::value_type>
00043 value_type;
00044
00045 typedef wifi::frame::filter::old_intersector<I1, I2, B1>
00046 iterable_type;
00047 };
00048
00049 template <class I1, class I2, class B>
00050 struct types< wifi::frame::filter::old_intersector<I1, I2, B> >
00051 {
00052 typedef wifi::frame::filter::internals::
00053 old_intersector_iterator<I1, I2, B, bottom>
00054 iterator;
00055 };
00056
00057 }
00058
00059
00060 namespace wifi
00061 {
00062 namespace frame
00063 {
00064 namespace filter
00065 {
00066
00067 namespace internals
00068 {
00069 template <class I1, class I2, class B, class Bottom = tool::bottom>
00070 struct old_intersector_iterator:
00071 WP_INHERIT(public tool::valued_iterator,
00072 old_intersector_iterator<I1, I2, B, Bottom>)
00073 {
00074
00076
00077 typedef WP_GET_EXACT(Bottom,
00078 old_intersector_iterator<I1, I2, B, Bottom>)
00079 exact_type;
00080 typedef tool::valued_iterator<exact_type> super_type;
00081 typedef WP_TYPE(value_type, exact_type) value_type;
00082 typedef WP_TYPE(iterable_type, exact_type) iterable_type;
00084
00086 old_intersector_iterator(const iterable_type& i, bool end);
00087
00089
00090 bool equal(const old_intersector_iterator& rhs) const;
00091 void increment();
00093
00094 private:
00095
00096 # ifdef WP_DONT_USE_HASH
00097 enum
00098 {
00109 arrivals_max_size = 1 << 20
00110 };
00111
00112 typedef std::set<typename I1::value_type> arrivals1_type;
00113 typedef std::set<typename I2::value_type> arrivals2_type;
00114 # else
00115 enum
00116 {
00126 arrivals_max_size = 1 << 20,
00127
00136 hash_bucket_count = arrivals_max_size * 4
00137 };
00138
00139 typedef tool::hash_set<typename I1::value_type> arrivals1_type;
00140 typedef tool::hash_set<typename I2::value_type> arrivals2_type;
00141 # endif
00142
00143 template <bool SwapResult, class ArrType, class RHSArrType>
00144 bool
00145 check(I1& frm,
00146 ArrType& frm_arrivals,
00147 RHSArrType& rhs_arrivals);
00148
00149 template <class ArrType>
00150 void
00151 cleanup_arrivals(const typename ArrType::iterator& frame,
00152 ArrType& arrivals);
00153
00154
00155 const iterable_type* iterable_;
00156
00157 I1 next1_;
00158 I2 next2_;
00159
00160 arrivals1_type arrivals1_;
00161 arrivals2_type arrivals2_;
00162 tool::microseconds last_arrival_[2];
00163 };
00164
00165 }
00166
00167
00168 template <class InputIterator1,
00169 class InputIterator2,
00170 class Bottom = tool::bottom>
00171 struct old_intersector:
00172 WP_INHERIT(public tool::iterable, old_intersector<InputIterator1,
00173 InputIterator2,
00174 Bottom>)
00175 {
00176 old_intersector(const InputIterator1& first1,
00177 const InputIterator1& last1,
00178 const InputIterator2& first2,
00179 const InputIterator2& last2);
00180
00181 private:
00182 InputIterator1 first1_;
00183 InputIterator1 last1_;
00184 InputIterator2 first2_;
00185 InputIterator2 last2_;
00186
00187 friend
00188 class internals::old_intersector_iterator<InputIterator1,
00189 InputIterator2,
00190 Bottom,
00191 tool::bottom>;
00192 };
00193
00194 }
00195
00196 }
00197
00198 }
00199
00200 # include "old_intersector.hxx"
00201
00202 #endif // ! WIFI_FRAME_FILTER_OLD_INTERSECTOR_HH_