Please enable JavaScript.
Coggle requires JavaScript to display documents.
STL - Coggle Diagram
STL
Containers
-
-
-
Note: We can compare the contents of the two containers
<, > , <= , >=, == etc.
IMPORTANT POINTS
- All the containers can store almost all the types of objects
- The container stores a copy of the element
- So the object must have its copy constructor
- Ordered associative containers must be able to compare elements, for comparing they use <, == so our objects must support these operators through operator overloading
Iterators
- It abstracts the container by hiding the implementation details and how it is stored simply allowing us to iterate over the sequence of elements
- They are objects but work like pointers
- Most container classes can be traversed through iterators
Few exceptions - Stack and Queue
begin() - points to the first element
end() - points to the location just after the last element
rbegin(), rend() - reverse iterators
cbegin(), cend() - constant iterators
crbegin(), crend() - reverse constant iterators
Algorithms
- sort - sorts the elements based on the comparator
sort(starting_iterator, end_iterator, comparator)
- reverse - reverses the elements
reverse(starting_iterator, end_iterator)
- accumulate - sums the range of elements
accumulate(starting_iterator, end_iterator, start_value)