c++ - Having a pair how to find if its part of some pair in map? -
c++ - Having a pair<string, string> how to find if its part of some pair in map<string, string>? -
we have pair of strings illustration such pair accept-language : ru ,
, search thru map, illustration of http request headers. ned know if there such pair in map or not - bool value. how soft search meaning not need find exact same pair pair accept-language : ru-ru,ru;q=0.8,en-us;q=0.6,en;q=0.4
valid pair , if such exists can think have found our map contains our pair. how create function performing such search in c++?
first of all, if using map
, cannot have multiple entries same key. e.g. can't have both accept-language : ru
, accept-language : ru-ru,ru;q=0.8,en-us;q=0.6,en;q=0.4
because have same key `accept-language'. perhaps in case should utilize vector of pairs, or multimap.
next, question consists of 2 parts:
how check, whether element (suchstring
or pair
) matches pattern. assuming have such check, how apply each element in container. the solutions each part:
you can implement function takesstring
, or pair
(depends on type of container , stored element choose), , checks whether matches criteria. can find functions such string::find_first_of useful matter. regex libraries can more helpful, though not part of stl. you can apply function on every element of container using find_if algorithm. c++ search stdmap std-pair
Comments
Post a Comment