Skip to content

Commit fb085e0

Browse files
authored
Update README.md
1 parent 6d4ff91 commit fb085e0

File tree

1 file changed

+74
-13
lines changed

1 file changed

+74
-13
lines changed

README.md

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ The containers are implemented as generic class templates, means that a containe
99

1010
Following are some common containers :
1111

12-
# vector : replicates arrays
13-
# queue : replicates queues
14-
# stack : replicates stack
15-
# priority_queue : replicates heaps
16-
# list : replicates linked list
17-
# set : replicates trees
18-
# map : associative arrays
12+
### vector : replicates arrays
13+
### queue : replicates queues
14+
### stack : replicates stack
15+
### priority_queue : replicates heaps
16+
### list : replicates linked list
17+
### set : replicates trees
18+
### map : associative arrays
1919

2020
# Classification of Containers in STL
2121
Containers are classified into four categories :
@@ -105,7 +105,8 @@ int main ()
105105
Site Link : https://www.studytonight.com/cpp/stl/stl-pair-template
106106

107107
# C++ My Codes :
108-
# Calculator
108+
109+
## Calculator
109110
```
110111
#include <iostream>
111112
using namespace std;
@@ -155,7 +156,7 @@ int main()
155156
return 0;
156157
}
157158
```
158-
# Container
159+
## Container
159160
```
160161
/*
161162
Container library is collection of classes
@@ -171,7 +172,7 @@ int main()
171172
return 0;
172173
}
173174
```
174-
# Function Templates
175+
## Function Templates
175176

176177
Templates are powerful features of C++ which allows you to write generic programs. In simple terms, you can create a single function or a class to work with different data types using templates.
177178
Templates are often used in larger codebase for the purpose of code reusability and flexibility of the programs.
@@ -226,7 +227,7 @@ int main()
226227
}
227228
```
228229

229-
# Pair Template
230+
## Pair Template
230231

231232
```
232233
/*Templates are powerful features of C++ which allows you to write generic programs. In simple terms, you can create a single function or a class to work with different data types using templates.
@@ -280,7 +281,7 @@ int main()
280281
return 0;
281282
}
282283
```
283-
# Swap Templates
284+
## Swap Templates
284285

285286
```
286287
#include<iostream>
@@ -319,7 +320,7 @@ int main()
319320
}
320321
```
321322

322-
# Vector Size
323+
## Vector Size
323324

324325
```
325326
#include<iostream>
@@ -347,3 +348,63 @@ int main()
347348
return 0;
348349
}
349350
```
351+
##
352+
```
353+
/*
354+
Array is collection of similar element
355+
STL has predefine class array
356+
like this
357+
array<int,4> obj;
358+
Here a array is formed with side 4
359+
to use this you need to include array
360+
template<place holder>
361+
class array{
362+
};
363+
*/
364+
#include<iostream>
365+
#include<array>
366+
using namespace std;
367+
int main()
368+
{
369+
array<int,4> data1={2,5,6,7};
370+
// use this extra array with swap
371+
array<int,4> data2={1,4,5,9};
372+
// we can also initilize it here
373+
// like this
374+
// array<int,4> data={2,5,6,8};}
375+
// it show some error
376+
// to fix it click on setting
377+
// if you are using dev then check on tool comiler option read the error and copy it on genneral add by tick
378+
cout<<data1.at(1)<<endl; // it show index array start from 0
379+
cout<<data1[2]<<endl;
380+
cout<<data1.front()<<endl;
381+
cout<<data1.back()<<endl;
382+
for(int i=0;i<=data1.size();i++)
383+
{
384+
cout<<data1[i]<<" ";
385+
}
386+
cout<<"\n";
387+
data1.fill(10);
388+
for(int i=0;i<=data1.size();i++)
389+
{
390+
391+
cout<<data1[i]<<" ";
392+
// to store 1 element in hole array
393+
}
394+
cout<<"\n";
395+
// swap
396+
data1.swap(data2);
397+
for(int i=0;i<=data1.size();i++)
398+
{
399+
cout<<data1[i]<<" ";
400+
}
401+
cout<<"\n";
402+
for(int i=0;i<=data2.size();i++)
403+
{
404+
cout<<data2[i]<<" ";
405+
}
406+
cout<<"\n";
407+
// to find the size
408+
cout<<data1.size();
409+
}
410+
```

0 commit comments

Comments
 (0)