00001 #ifndef NMWR_GB_CONTAINER_ADAPTER_H 00002 #define NMWR_GB_CONTAINER_ADAPTER_H 00003 00004 00005 // $LICENSE 00006 00007 #include "Container/mapped-value-iterator.h" 00008 00009 //---------------------------------------------------------------- 00024 template<class Cont> 00025 class ValueMask { 00026 private: 00027 const Cont* the_container; 00028 public: 00029 typedef typename Cont::value_type base_value_type; 00030 typedef typename Cont::const_iterator base_iter; 00031 typedef get_second<base_value_type> functor_type; 00032 00033 typedef mapped_value_const_iterator<base_iter,functor_type> const_iterator; 00034 typedef typename const_iterator::value_type value_type; 00035 00036 ValueMask(const Cont& c) : the_container(&c) {} 00037 00038 const_iterator begin() const 00039 { return const_iterator(the_container->begin(),functor_type()); } 00040 const_iterator end() const 00041 { return const_iterator(the_container->end(),functor_type()); } 00042 00043 unsigned size() const { return the_container->size();} 00044 }; 00045 00046 00047 template<class Cont> 00048 inline ValueMask<Cont> 00049 values_of(const Cont& c) { return ValueMask<Cont>(c);} 00050 00051 #endif 00052