Stl Cheat Sheet



Cheat

There are a ton of detailed references available for STL. Even several bookswritten about them. But I want cheat sheets long enough to explicitly tell mehow to use them and implicitly, tell me why/when to use them. C++ STL containsstupefyingly useful algorithms. I will just arbitrarily list them here forreference (not comprehensive by any means). It’s a little hard to do thiseasily, so I am going to start here:

List of Useful STL Algorithms

STL Cheat Sheet Creation. Make an empty vector of integers. Vector iseq1;. Make a 10-element vector of doubles, each initialized to -1. Vector iseq2( 10, -1 );. A value that is a 10-element vector of ints, each initialized to 50. Vector( 10, 50 );. Function parameters and return values may be of any type. A function must either be declared or defined before it is used. It may be declared first and defined later.

std::find_if:

find odd

std::transform:

std::stable_partition:

pivot_ is an iterator with prime nos. before and composites after

std::rotate:

std::is_permutation:

std::next_permutation:

std::lower_bound:

std::move_backward:

std::any_of:

std::lexicographical_compare:

std::adjacent_find:

This snippet finds words that are out of dictionary order

std::is_permutation:

std::count_if:

std::for_each:

Stl Cheat Sheet

std::equal:

std::set_intersection:

std::binary_search:

Stl Cheat SheetStl siemens cheat sheet

std::unique:

Useful in merging adjacent/consecutive equal entrieslike merging intervals, even.

Stl-cheat-sheet-by-category.pdf

Merging Vectors: std::move:

Stl cheat sheet pdf

v2 is the final vectorv1 is the arr to be merged/deleted

std::priority_queue:

S5 Stl Cheat Sheet

comp is a predicate to compareonly it’s type is passed hereNote: A priority queue cannot be iterated over

Please enable JavaScript to view the comments powered by Disqus.comments powered by

Stl Cheat Sheet C++

Disqus

Stl Cheat Sheet Pdf