You are on page 1of 8

STANDARD

TEMPLATE LIBRARY :

OBJECT ORIENTED PROGRAMMING


Components of STL



OBJECT ORIENTED PROGRAMMING


• Uniqueness Its resemblance with
• Sorted mathematics SET:
• Immutable A = { 1, 2, 5, 7}
• Unindexed
• Internal Implementation - B = {a, e, i, o, u}
Red Black Tree

OBJECT ORIENTED PROGRAMMING


#include<set>
• To declare a template of datatype T:
set<T> st; //basic STL declarations
e.g.:
set<int> st; //set to hold integers only

• To use a set template with datatype class:


set<ClassName> st; //basic STL declarations
e.g.:
Class Person{};
int main()
{ set<Person> st; //set to hold integers only }

OBJECT ORIENTED PROGRAMMING


The initialization of a Set involves defining the data type for the elements to be
stored and the order in which they are to be stored.

C++ has a concept of iterators for each specific STL data structure. Since a Set
does not support indexing, we need to define iterators to fetch its element.

Iterators are used to point at the memory addresses of STL containers.

Operations of iterators :-
• begin()
• end()
• *it

OBJECT ORIENTED PROGRAMMING


• insert()
• erase()
• lower_bound()
• upper_bound()
• find()
• clear()
• empty()

OBJECT ORIENTED PROGRAMMING


• https://onlinegdb.com/ta8JJeW3z

• https://onlinegdb.com/7cqaUOixz

• https://onlinegdb.com/wYdtNIiQP

OBJECT ORIENTED PROGRAMMING


NAME:
Maitri Shah

ROLL NO.
I057

BATCH: I3
B.TECH AI

You might also like