{"id":1048,"date":"2011-01-21T15:47:16","date_gmt":"2011-01-21T20:47:16","guid":{"rendered":"http:\/\/bitpost.com\/news\/?p=1048"},"modified":"2022-08-26T14:04:38","modified_gmt":"2022-08-26T18:04:38","slug":"cross-platform-c-sorted_vector-derived-from-stdvector","status":"publish","type":"post","link":"https:\/\/bitpost.com\/news\/2011\/cross-platform-c-sorted_vector-derived-from-stdvector\/","title":{"rendered":"Cross-platform C++ sorted_vector derived from std::vector"},"content":{"rendered":"<p><a href=\"https:\/\/gitlab.com\/moodboom\/reusable\/-\/blob\/master\/c%2B%2B\/STLContainers.h\">Here<\/a> is my published reusable c++ code, which includes a version of a sorted vector that I&#8217;ve been using for years. It may not be academically sterile C++, I&#8217;m more interested in getting things done, and I had to crank out some new functionality needed for my upcoming media manager. But it should be solid production code. It glues together std::vector with std::sort, std::lower_bound, etc., which is a pretty fscking logical thing to do &#8211; who wants to redo that every time you have data to manage? :&gt; My favorite part is the find_it_or_fail() function, the only real extension of functionality. Basically, it extends lower_bound() in a logical way, so you either get a hit, or failure (indicated by returning vector::end()). There are also versions of member functions with predicate function parameters, to help you use it with vectors of object pointers, which isn&#8217;t exactly straightforward in C++. Let me know if it seems useful or sucky. :&gt;<\/p>\n<p><center><a href=\"https:\/\/gitlab.com\/moodboom\/reusable\/-\/blob\/master\/c%2B%2B\/STLContainers.h\">Reusable STLContainers code<\/a><\/center><center><\/center><center><a href=\"https:\/\/bitpost.com\/wiki\/C%2B%2B_sorted_vector\">old wiki copy of sorted_vector<\/a><\/center><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is my published reusable c++ code, which includes a version of a sorted vector that I&#8217;ve been using for years. It may not be academically sterile C++, I&#8217;m more interested in getting things done, and I had to crank out some new functionality needed for my upcoming media manager. But it should be solid [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[22],"tags":[31,29,30],"class_list":["post-1048","post","type-post","status-publish","format-standard","hentry","category-cpp","tag-data-structures","tag-sorted_vector","tag-stl"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9M11L-gU","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/1048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/comments?post=1048"}],"version-history":[{"count":9,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/1048\/revisions"}],"predecessor-version":[{"id":2524,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/1048\/revisions\/2524"}],"wp:attachment":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/media?parent=1048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/categories?post=1048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/tags?post=1048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}