00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TOOL_LIST_OF_ITERABLES_HH_
00023 # define TOOL_LIST_OF_ITERABLES_HH_
00024
00025 # include <queue>
00026 # include <vector>
00027
00028 # include <wipal/tool/iterable.hh>
00029 # include <wipal/tool/iterator.hh>
00030
00031 namespace tool
00032 {
00033
00034
00035
00036
00037
00038 template <class T, class B>
00039 struct list_of_iterables;
00040
00041 template <class T, class B1, class B2>
00042 struct list_of_iterables_iterator;
00043
00044
00045
00046
00047
00048 template <class T, class B, class Bottom>
00049 struct types< list_of_iterables_iterator<T, B, Bottom> >
00050 {
00051 typedef typename T::iterator::value_type value_type;
00052 typedef list_of_iterables<T, B> iterable_type;
00053 };
00054
00055 template <class T, class B>
00056 struct types< list_of_iterables<T, B> >
00057 {
00058 typedef list_of_iterables_iterator<T, B, bottom> iterator;
00059 };
00060
00061
00062
00063
00064
00065 template <class T, class B, class Bottom = bottom>
00066 struct list_of_iterables_iterator:
00067 wp_inherit(public iterator, list_of_iterables_iterator<T, B, Bottom>)
00068 {
00069 typedef wp_get_exact(Bottom, list_of_iterables_iterator<T, B, Bottom>)
00070 exact_type;
00071 typedef iterator<exact_type> super_type;
00072 typedef wp_type(value_type, exact_type) value_type;
00073 typedef wp_type(iterable_type, exact_type) iterable_type;
00074
00075 list_of_iterables_iterator(const iterable_type&, bool);
00076
00077 bool equal(const exact_type&) const;
00078 void increment();
00079
00080 const value_type& get() const;
00081 const value_type* get_ptr() const;
00082
00083 private:
00084 typedef typename T::const_iterator inner_iterator_type;
00085
00086 std::queue<inner_iterator_type> begins_;
00087 std::queue<inner_iterator_type> ends_;
00088 };
00089
00090 template <class T, class Bottom = tool::bottom>
00091 struct list_of_iterables: wp_inherit(public iterable,
00092 list_of_iterables<T, Bottom>)
00093 {
00094 typedef wp_get_exact(Bottom, list_of_iterables<T, Bottom>) exact_type;
00095 typedef iterable<exact_type> super_type;
00096
00097 list_of_iterables();
00098
00099 template <class L>
00100 list_of_iterables(const L& list);
00101
00102 bool empty() const;
00103 size_t size() const;
00104
00105 exact_type& push_back(const T&);
00106
00107 const T& iterable(unsigned i) const;
00108 T& iterable(unsigned i);
00109
00110 private:
00111 std::vector<T> list_;
00112
00113 friend class list_of_iterables_iterator<T, Bottom, bottom>;
00114 };
00115
00116 }
00117
00118 # include "list_of_iterables.hxx"
00119
00120 #endif // ! TOOL_ITERABLE_HH_