C++ Flashcards
Import dictionary
import <unordered_set></unordered_set>
Import dynamic array
include <vector></vector>
Insert element in a dynamic array
arrayName.push_back(element);
Sort dynamic array
include <algorithm></algorithm>
sort(array.begin(), array.end());
Loop through elements in an array
for(int element : array)
Declare a set
unordered_set<int> newSet;</int>
Add element to a set
newSet.insert(element);
Check element is in a set
if( newSet.find(potentialElement) != newSet.end() )
Array length
array.size()
Absolute value
include <cmath></cmath>
abs(value);
Get last element in an array
array.back();
Using auto types
include <any></any>
auto element;
int intVariable = any_cast<int>(element);</int>
Int min/max
include <climits></climits>
INT_MIN
INT_MAX
Short min/max
include <climits></climits>
SHRT_MIN
SHRT_MAX
Unsigned max
include <climits></climits>
UINT_MAX
Long min/max
include <climits></climits>
LONG_MIN
LONG_MAX