c++ - Is there a design reason why std::set doesnt have front and back member functions? -
- i know can use
*s.begin()
, same argument can usedvector
, hasfront
/back
- often use ordered property of set/map "smallest" element/key - ofc fact i not reason have it, example :)
here i'm talking design reasons why front
/back
bad design, please skip obvious reasons committee forgot it...
i imagine words "front" , "back" reserved sequence containers (i.e. order of elements determined order of insertion), , words meant suggest physical position in sequence.
since set
not sequence container (but instead associative container), isn't appropriate. in particular, note meaning of "front" can change later insertions of unrelated element.
Comments
Post a Comment