C++.Coding.Standards.1918.Rules.Guidelines [Electronic resources]

Herb Sutter, Andrei Alexandrescu

نسخه متنی -صفحه : 521/ 438
نمايش فراداده

Summary

Search "just enough"the right search may be STL (slower than light), but it'll still be pretty fast: This Item applies to searching for a particular value in a range, or for the location where it would be if it were in the range. To search an unsorted range, use

find /

find_if or

count /

count_if . To search a sorted range, use

lower_bound, upper_bound, equal_range , or (rarely)

binary_search . (Despite its common name,

binary_search is usually not the right choice.)