src/include/maps.h
changeset 349 42c660f58702
parent 345 d8c452d54d37
child 389 770cc1f4861f
equal deleted inserted replaced
1:9691c9fe5735 2:b769989c6f9c
    93     
    93     
    94     template<typename T1, typename Comp1>
    94     template<typename T1, typename Comp1>
    95     StdMap(const StdMap<Key,T1,Comp1> &m, const T &_v) { FIXME; }
    95     StdMap(const StdMap<Key,T1,Comp1> &m, const T &_v) { FIXME; }
    96 
    96 
    97     ReferenceType operator[](const Key &k) {
    97     ReferenceType operator[](const Key &k) {
    98       return (  *( (insert(PairType(k,v))).first )  ).second;
    98       return insert(PairType(k,v)).first -> second;
    99     }
    99     }
   100     ConstReferenceType operator[](const Key &k) const {
   100     ConstReferenceType operator[](const Key &k) const {
   101       typename parent::iterator i = lower_bound(__k);
   101       typename parent::iterator i = lower_bound(__k);
   102       if (i == end() || key_comp()(k, (*i).first))
   102       if (i == end() || key_comp()(k, (*i).first))
   103 	return v;
   103 	return v;
   104       return (*i).second;
   104       return (*i).second;
   105     }
   105     }
   106     void set(const Key &k, const T &t) {
   106     void set(const Key &k, const T &t) {
   107       // tyuha, ez valamiert segfault-olt igy:
   107       parent::operator[](k) = t;
   108       // parent::operator[](k) = t;
       
   109       (  *( (insert(PairType(k,t))).first )  ).second=t;
       
   110     }
   108     }
   111 
   109 
   112     /// Changes the default value of the map.
   110     /// Changes the default value of the map.
   113     /// \return Returns the previous default value.
   111     /// \return Returns the previous default value.
   114     ///
   112     ///