Loading...
Preparing your coding drills
Comprehensive reference for 43 C++ methods across 6 categories.
push_back
Adds an element to the end of the vector. May cause reallocation if capacity is exceeded.
pop_back
Removes the last element from the vector. Does not return the removed element.
emplace_back
Constructs an element in-place at the end of the vector. More efficient than push_back for complex types.
size
Returns the number of elements in the vector.
empty
Checks if the vector has no elements.
at
Returns a reference to the element at specified position with bounds checking.
front
Returns a reference to the first element in the vector.
back
Returns a reference to the last element in the vector.
clear
Removes all elements from the vector. Capacity remains unchanged.
insert
Inserts elements at the specified position in the vector.
erase
Removes elements from the vector at the specified position or range.
reserve
Requests that the vector capacity be at least enough to contain n elements.
resize
Resizes the container to contain count elements.
substr
Returns a substring starting at pos with length count.
find
Finds the first occurrence of the substring. Returns npos if not found.
append
Appends characters to the end of the string.
replace
Replaces part of the string with another string.
c_str
Returns a pointer to a null-terminated character array.
compare
Compares two strings lexicographically.
sort
Sorts elements in the range [first, last) in ascending order or using a custom comparator.
binary_search
Checks if an element exists in a sorted range.
lower_bound
Returns iterator to first element not less than value in sorted range.
upper_bound
Returns iterator to first element greater than value in sorted range.
Finds the first element equal to value in the range.
find_if
Finds the first element satisfying the predicate.
count
Counts the number of elements equal to value.
reverse
Reverses the order of elements in the range.
unique
Removes consecutive duplicate elements. Usually used with erase idiom.
max_element
Finds the largest element in the range.
min_element
Finds the smallest element in the range.
accumulate
Computes the sum of init and all elements in the range.
transform
Applies a function to each element and stores the result.
Inserts element(s) if key does not exist.
Finds an element with the specified key.
Returns the number of elements with the specified key (0 or 1 for map, 0+ for multimap).
Removes elements from the map.
Inserts an element if it does not already exist.
Finds an element with the specified value.
Returns 1 if the value exists, 0 otherwise.
push
Adds an element to the stack (top) or queue (back).
pop
Removes the top element (stack) or front element (queue). Does not return the element.
top
Returns a reference to the top element of the stack.
Returns a reference to the front element of the queue.