SlideShare a Scribd company logo
[KOSSA] C++ Programming - 15th Study - STL #1
[KOSSA] C++ Programming - 15th Study - STL #1
3
Bijarne Stroustrup
Alexander Stepanov
4
http://ko.wikipedia.org/wiki/표준_템플릿_라이브러리
5
6
7
8
[KOSSA] C++ Programming - 15th Study - STL #1
10
[KOSSA] C++ Programming - 15th Study - STL #1
12
 std::vector
 std::deque
 std::list
[KOSSA] C++ Programming - 15th Study - STL #1
14
15
배열 std::vector
16
17
18
#include <vector> // 해더 파일
std::vector<int> vec; // 선언
vec.push_back(10); // 추가
vec.pop_back(); // 삭제
vec.resize(10, 0); // 초기화 : 10의 크기를 0으로 채움
vec[3] = 10; // 랜덤 접근
std::cout << vec[3] << std::endl; // 랜덤 접근
19
int nSum = 0;
for (int i = 0; i < vec.size(); i++)
{
nSum += vec[i];
}
// auto = std::iterator<std::vector<int>>
for (auto it = vec.begin(); it != vec.end(); it++)
{
nSum += (*it);
}
[KOSSA] C++ Programming - 15th Study - STL #1
21
std::vector
22
23
#include <deque> // 해더 파일
std::deque<int> deq; // 선언
deq.push_back(10); // 뒤에 추가
deq.pop_back(); // 뒤에 삭제
deq.push_front(20); // 앞으로 추가
deq.pop_front(); // 앞에 삭제
deq.resize(10, 0); // 초기화 : 10의 크기를 0으로 채움
deq[3] = 10; // 랜덤 접근
std::cout << deq[3] << std::endl; // 랜덤 접근
24
int nSum = 0;
for (int i = 0; i < deq.size(); i++)
{
nSum += vec[i];
}
// auto = std::vector<int>::iterator
for (auto it = deq.begin(); it != deq.end(); it++)
{
nSum += (*it);
}
[KOSSA] C++ Programming - 15th Study - STL #1
26
27
28
29
#include <list>
std::list<int> lst;
lst.push_back(5); // 5
lst.push_back(10); // 5 -> 10
lst.push_front(1); // 1 -> 5 -> 10
auto it = lst.begin(); // 첫번째 위치, it -> 1 -> 5 -> 10
it++; // 두번째 위치, 1 -> it -> 5 -> 10
auto at = lst.insert(it, 2); // 2 삽입, 1 -> at -> 2 -> it -> 5 -> 10
lst.insert(at, 3); // 1 -> 3 -> at -> 2 -> it -> 5 -> 10
lst.insert(it, 4); // 1 -> 3 -> at -> 2 -> 4 -> it -> 5 -> 10
for (auto iter = lst.begin(); iter != lst.end(); iter++)
std::cout << (*iter) << 't';
30
std::list<int> lstB;
lstB.push_back(20); // 20
lstB.push_back(30); // 20 -> 30
// 1 -> 3 -> at -> 2 -> 4 -> it -> 5 -> 10
lst.insert(it, lstB.begin(), lstB.end());
// 1 -> 3 -> at -> 2 -> 4 -> 20 -> 30 -> it -> 5 -> 10
for (auto iter = lst.begin(); iter != lst.end(); iter++)
std::cout << (*iter) << 't';
std::cout << std::endl;

More Related Content

PPTX
망고100 보드로 놀아보자 3
PDF
어플 개발자의 서버개발 삽질기
PDF
2. c언어의 기본
PPTX
AIbyExample - Ch7 raven. version 0.8
PPTX
190821 delphi
DOCX
TestBCD2018-2(answer)
PDF
5 1. character processing
PPTX
Programming Game AI by Example. Ch7. Raven
망고100 보드로 놀아보자 3
어플 개발자의 서버개발 삽질기
2. c언어의 기본
AIbyExample - Ch7 raven. version 0.8
190821 delphi
TestBCD2018-2(answer)
5 1. character processing
Programming Game AI by Example. Ch7. Raven

What's hot (14)

PDF
[KOSSA] C++ Programming - 13th Study - exception handling
PDF
Geveloper 160816
PPTX
만들면서배우는Cocos2d-x(12-13)
PDF
Es2015 Simple Overview
PPTX
6장 performance of game_최준혁_2
PDF
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
PDF
Data Structure - 1st Study
PDF
Hello c++ world
PDF
바다 앱 개발 실패 노하우 1부
PDF
2 1. variables & data types
PDF
Shellscript에 대하여
PPTX
Startup JavaScript 3 - 조건문, 반복문, 예외처리
PDF
[JS] Function.prototype.bind
PDF
JavaScript Promises
[KOSSA] C++ Programming - 13th Study - exception handling
Geveloper 160816
만들면서배우는Cocos2d-x(12-13)
Es2015 Simple Overview
6장 performance of game_최준혁_2
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
Data Structure - 1st Study
Hello c++ world
바다 앱 개발 실패 노하우 1부
2 1. variables & data types
Shellscript에 대하여
Startup JavaScript 3 - 조건문, 반복문, 예외처리
[JS] Function.prototype.bind
JavaScript Promises
Ad

Similar to [KOSSA] C++ Programming - 15th Study - STL #1 (20)

PDF
ffmpeg optimization using CUDA
PDF
2012 Ds D2 03
PPTX
[NDC2015] C++11 고급 기능 - Crow에 사용된 기법 중심으로
PDF
프로그래밍 대회: C++11 이야기
PDF
2012 Ds D2 03 Pdf
PPTX
불어오는 변화의 바람, From c++98 to c++11, 14
PPTX
20150212 c++11 features used in crow
PDF
11. array & pointer
PDF
C++17 Key Features Summary - Ver 2
PDF
[Swift] Data Structure - Graph(BFS)
PPTX
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
PPT
Boost라이브러리의내부구조 20151111 서진택
PPTX
Functional programming
PDF
2012 Dm A0 04 Pdf
PDF
2012 Dm A0 04 Pdf
DOCX
MapReduce 실행 샘플 (K-mer Counting, K-means Clustering)
PPTX
포트폴리오에서 사용한 모던 C++
PPTX
[devil's camp] - 알고리즘 대회와 STL (박인서)
PDF
Data Structure. Linked List
PPTX
Bs webgl소모임002
ffmpeg optimization using CUDA
2012 Ds D2 03
[NDC2015] C++11 고급 기능 - Crow에 사용된 기법 중심으로
프로그래밍 대회: C++11 이야기
2012 Ds D2 03 Pdf
불어오는 변화의 바람, From c++98 to c++11, 14
20150212 c++11 features used in crow
11. array & pointer
C++17 Key Features Summary - Ver 2
[Swift] Data Structure - Graph(BFS)
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
Boost라이브러리의내부구조 20151111 서진택
Functional programming
2012 Dm A0 04 Pdf
2012 Dm A0 04 Pdf
MapReduce 실행 샘플 (K-mer Counting, K-means Clustering)
포트폴리오에서 사용한 모던 C++
[devil's camp] - 알고리즘 대회와 STL (박인서)
Data Structure. Linked List
Bs webgl소모임002
Ad

More from Seok-joon Yun (20)

PDF
Retrospective.2020 03
PDF
Sprint & Jira
PPTX
Eks.introduce.v2
PDF
Eks.introduce
PDF
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
PDF
아파트 시세,어쩌다 머신러닝까지
PPTX
Pro typescript.ch07.Exception, Memory, Performance
PPTX
Doing math with python.ch07
PPTX
Doing math with python.ch06
PPTX
Doing math with python.ch05
PPTX
Doing math with python.ch04
PPTX
Doing math with python.ch03
PPTX
Doing mathwithpython.ch02
PPTX
Doing math with python.ch01
PPTX
Pro typescript.ch03.Object Orientation in TypeScript
PDF
C++ Concurrency in Action 9-2 Interrupting threads
PDF
Welcome to Modern C++
PDF
[2015-07-20-윤석준] Oracle 성능 관리 2
PDF
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
PDF
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
Retrospective.2020 03
Sprint & Jira
Eks.introduce.v2
Eks.introduce
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
아파트 시세,어쩌다 머신러닝까지
Pro typescript.ch07.Exception, Memory, Performance
Doing math with python.ch07
Doing math with python.ch06
Doing math with python.ch05
Doing math with python.ch04
Doing math with python.ch03
Doing mathwithpython.ch02
Doing math with python.ch01
Pro typescript.ch03.Object Orientation in TypeScript
C++ Concurrency in Action 9-2 Interrupting threads
Welcome to Modern C++
[2015-07-20-윤석준] Oracle 성능 관리 2
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4

[KOSSA] C++ Programming - 15th Study - STL #1

  • 5. 5
  • 6. 6
  • 7. 7
  • 8. 8
  • 10. 10
  • 14. 14
  • 16. 16
  • 17. 17
  • 18. 18 #include <vector> // 해더 파일 std::vector<int> vec; // 선언 vec.push_back(10); // 추가 vec.pop_back(); // 삭제 vec.resize(10, 0); // 초기화 : 10의 크기를 0으로 채움 vec[3] = 10; // 랜덤 접근 std::cout << vec[3] << std::endl; // 랜덤 접근
  • 19. 19 int nSum = 0; for (int i = 0; i < vec.size(); i++) { nSum += vec[i]; } // auto = std::iterator<std::vector<int>> for (auto it = vec.begin(); it != vec.end(); it++) { nSum += (*it); }
  • 22. 22
  • 23. 23 #include <deque> // 해더 파일 std::deque<int> deq; // 선언 deq.push_back(10); // 뒤에 추가 deq.pop_back(); // 뒤에 삭제 deq.push_front(20); // 앞으로 추가 deq.pop_front(); // 앞에 삭제 deq.resize(10, 0); // 초기화 : 10의 크기를 0으로 채움 deq[3] = 10; // 랜덤 접근 std::cout << deq[3] << std::endl; // 랜덤 접근
  • 24. 24 int nSum = 0; for (int i = 0; i < deq.size(); i++) { nSum += vec[i]; } // auto = std::vector<int>::iterator for (auto it = deq.begin(); it != deq.end(); it++) { nSum += (*it); }
  • 26. 26
  • 27. 27
  • 28. 28
  • 29. 29 #include <list> std::list<int> lst; lst.push_back(5); // 5 lst.push_back(10); // 5 -> 10 lst.push_front(1); // 1 -> 5 -> 10 auto it = lst.begin(); // 첫번째 위치, it -> 1 -> 5 -> 10 it++; // 두번째 위치, 1 -> it -> 5 -> 10 auto at = lst.insert(it, 2); // 2 삽입, 1 -> at -> 2 -> it -> 5 -> 10 lst.insert(at, 3); // 1 -> 3 -> at -> 2 -> it -> 5 -> 10 lst.insert(it, 4); // 1 -> 3 -> at -> 2 -> 4 -> it -> 5 -> 10 for (auto iter = lst.begin(); iter != lst.end(); iter++) std::cout << (*iter) << 't';
  • 30. 30 std::list<int> lstB; lstB.push_back(20); // 20 lstB.push_back(30); // 20 -> 30 // 1 -> 3 -> at -> 2 -> 4 -> it -> 5 -> 10 lst.insert(it, lstB.begin(), lstB.end()); // 1 -> 3 -> at -> 2 -> 4 -> 20 -> 30 -> it -> 5 -> 10 for (auto iter = lst.begin(); iter != lst.end(); iter++) std::cout << (*iter) << 't'; std::cout << std::endl;