The C++ Standard Template Library (STL) consists of three main components: containers, algorithms, and iterators. Containers provide data structures for storing collections of data, algorithms provide functions for operating on containers, and iterators facilitate the use of containers with algorithms. STL was adopted as part of the ISO C++ standard in 1994. STL offers containers like vectors and maps, publicizes complexity guarantees, and provides built-in algorithms for processing containers in an extensible way. The C++ standard library also provides a string class for representing strings.
Trauma-Informed Leadership - Five Practical Principles
Standard libraries
1.
2.
3. The C++ Standard
arrangement Libraries
STL had three basic components
- Package
Generic class arrangement for storing collection of data.
Method
Generic function arrangement for operating on containers.
Emphasize
Generalized ‘smart’ pointers that facilitate use of package
They provide an interface that is needed for method to operate
on packages
String abstraction was added during
standardization.
4. In 1990, Alex of Hewlett Packard
Laboratories extended C++ with a library
of fine and operations arrangement
which has come to be known as the
Standard .
In 1994, was adopted as part of
ANSI/ISO Standard C++.
5. Use of STL
STL offers an assortment of Packages
STL publicizes the time and storage complexity of its
packages
STL packages grow and shrink in size automatically
STL provides built-in algorithms for processing
packages
STL provides emphasize that make the packages and
methods flexible and efficient.
STL is extensible which means that users can add new
packages and new methods such that:
STL methods can process STL packages as well as user
defined packages
User defined method can process STL packages as well user
defined packages
6. Strings
In C we used char * to represent a string.
The C++ standard library provides a common
implementation of a string fine entrancement
named string.
8. Creating strings
string str = “some text”;
or
string str(“some text”);
other ways:
string s1(7,„a‟);
string s2 = s1;
9. The size method
str.size() ???
In C we had structs containing only data,
In C++, we have :
class string
{
…
public:
…
unsigned int size();
…
};
10. String assignment
To assign one string to another
use the “=“ operator.
string str1 = “Sgt. Pappers”;
string str2 = “lonely hearts club bend”;
str2 = str1;
Now : str2 equals “Sgt. Pappers”
11. Containers
Data structures that hold anything (other
objects).
list: doubly linked list.
vector: similar to a C array, but
dynamic.
map: set of ordered key/value
pairs.
Set: set of ordered keys.
12. Vector
Provides an alternative to the built in array.
A vector is self grown.
Use It instead of the built in array!