-
Notifications
You must be signed in to change notification settings - Fork 0
/
stlbasics.cpp
53 lines (48 loc) · 1.7 KB
/
stlbasics.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
stl:standard template library
library of what???
|->generic classes and function
why use stl?
|---> reuse, well tested component
|--> time saving
****component of stl****
1.container
--store data , use templates
2.algorithm
---sorting , searching,use template function
3.iteration
---- object point to an element in container.
----handle just like pointer.
----connect algorithm with container
//STL IS USED BECAUSE IT IS GOOD IDEA
//NOT TO REINVENT THE WHEEL.
@@---@-----@@---@@-----@@---@@@-----@@---@@----@@---@@@----@@---@--@^^^@
..---.-----..---..-----..---...-----..---..----..---...----..---.--.^^^.
**---*-----**---**-----**---***-----**---**----**---***----**---*--*^^^*
##---#-----##---##-----##---##------##---##----##---###----##---#--#^^^##
types of container
1.sequence container
--linear fashion example:vector,list,dequeue
2.associative container:direct access(it's like tree)||
--ex:set/multi-set,map/multi-map
3.derived container||-
---real world modeling
ex:
stack
queue priority queue
when to use which container?
1.SEQUENCE CONTAINER:
*VECTOR
RANDOM ACCESS FAST
MIDDLE INSERTION AND DELETION SLOW
DELETION AND INSERTION AT END IS FAST
*LIST:
random access slow
middle insertion is fast
deletion and insertion at the end is fast
2.ASSOCIATIVE CONTAINER:
all operation is fast except random access
3. DERIVED CONTAINER:
DEPENDS NOT FIXED
*LIST
*/