00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TOOL_WINDOW_HXX_
00023 # define TOOL_WINDOW_HXX_
00024
00025 # include "window.hxx"
00026
00027 namespace tool
00028 {
00029
00030 template <class I, unsigned Ws, unsigned S, class B>
00031 template <class Iterable>
00032 window<I, Ws, S, B>::window(Iterable& i, bool end):
00033 at_end_ (end),
00034 next_ (end ? i.last_ : i.first_),
00035 last_ (i.last_),
00036 v_ ()
00037 {
00038 for (unsigned i = 0; next_ != last_ and i < Ws; ++i)
00039 v_.push_back(*next_++);
00040 }
00041
00042 template <class I, unsigned Ws, unsigned S, class B>
00043 bool
00044 window<I, Ws, S, B>::equal(const window& rhs) const
00045 {
00046 return
00047 at_end_ == rhs.at_end_ and next_ == rhs.next_ and last_ == rhs.last_;
00048 }
00049
00050 template <class I, unsigned Ws, unsigned S, class B>
00051 void
00052 window<I, Ws, S, B>::increment()
00053 {
00054 if (next_ == last_)
00055 at_end_ = true;
00056 else
00057 for (unsigned i = 0; i < S; ++i)
00058 {
00059 v_.pop_front();
00060 if (next_ != last_)
00061 v_.push_back(*next_++);
00062 }
00063 }
00064
00065 template <class I, unsigned Ws, unsigned S, class B>
00066 const typename window<I, Ws, S, B>::value_type&
00067 window<I, Ws, S, B>::get() const
00068 {
00069 return v_;
00070 }
00071
00072 template <class I, unsigned Ws, unsigned S, class B>
00073 const typename window<I, Ws, S, B>::value_type*
00074 window<I, Ws, S, B>::get_ptr() const
00075 {
00076 return &v_;
00077 }
00078
00079 template <class I, unsigned Ws, unsigned S, class B>
00080 const typename I::value_type&
00081 window<I, Ws, S, B>::operator [] (unsigned i) const
00082 {
00083 return v_[i];
00084 }
00085
00086 template <class I, unsigned Ws, unsigned S, class B>
00087 window_maker<I, Ws, S, B>::window_maker(const I& first, const I& last):
00088 first_ (first),
00089 last_ (last)
00090 {
00091 }
00092
00093 }
00094
00095 #endif // ! TOOL_WINDOW_HXX_