00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MLN_VALUE_INTERNAL_ITERABLE_SET_HH
00027 # define MLN_VALUE_INTERNAL_ITERABLE_SET_HH
00028
00034 # include <mln/core/concept/value_set.hh>
00035 # include <mln/trait/value_.hh>
00036 # include <mln/value/builtin/all.hh>
00037 # include <mln/value/internal/convert.hh>
00038
00039
00040 namespace mln
00041 {
00042
00043 namespace value
00044 {
00045
00046
00047 template <typename S> struct fwd_viter_;
00048 template <typename S> struct bkd_viter_;
00049
00050
00051 namespace internal
00052 {
00053
00057 template <typename T, typename E>
00058 struct iterable_set : public Value_Set<E>
00059 {
00061 typedef T value;
00062
00064 typedef fwd_viter_<E> fwd_viter;
00065
00067 typedef bkd_viter_<E> bkd_viter;
00068
00070 bool has(const T& v) const;
00071
00073 T operator[](unsigned i) const;
00074
00076 unsigned index_of(const T& v) const;
00077
00079 unsigned nvalues() const;
00080
00081 };
00082
00083
00084
00085 # ifndef MLN_INCLUDE_ONLY
00086
00087 template <typename T, typename E>
00088 inline
00089 bool
00090 iterable_set<T,E>::has(const T&) const
00091 {
00092 return true;
00093 }
00094
00095 template <typename T, typename E>
00096 inline
00097 T
00098 iterable_set<T,E>::operator[](unsigned i) const
00099 {
00100 mln_precondition(i < nvalues());
00101 return mln::value::internal::convert_<T>::value_at_index(i);
00102 }
00103
00104 template <typename T, typename E>
00105 inline
00106 unsigned
00107 iterable_set<T,E>::index_of(const T& v) const
00108 {
00109 return mln::value::internal::convert_<T>::index_of_value(v);
00110 }
00111
00112 template <typename T, typename E>
00113 inline
00114 unsigned
00115 iterable_set<T,E>::nvalues() const
00116 {
00117 return mln_card(T);
00118 }
00119
00120 # endif // ! MLN_INCLUDE_ONLY
00121
00122 }
00123
00124 }
00125
00126 }
00127
00128
00129 # include <mln/value/viter.hh>
00130
00131
00132 #endif // ! MLN_VALUE_INTERNAL_ITERABLE_SET_HH