SlideShare a Scribd company logo
[KOSSA] C++ Programming - 17th Study - STL #3
[KOSSA] C++ Programming - 17th Study - STL #3
3
4
[KOSSA] C++ Programming - 17th Study - STL #3
6
http://www.cplusplus.com/reference/algorithm
7
template<class InputIterator, class Type>
InputIterator find(InputIterator _First, InputIterator _Last, const Type& _Val);
8
#include <iostream>
#include <vector>
#include <algorithm>
void main()
{
std::vector<int> V{ 10, 20, 30, 40, 50 };
auto it30 = std::find(V.begin(), V.end(), 30);
auto it25 = std::find(V.begin(), V.end(), 25);
if (it30 != V.end())
std::cout << "Find 30 !" << std::endl;
if (it25 != V.end())
std::cout << "Find 25 !" << std::endl;
}
9
template<class InputIterator, class Predicate>
InputIterator find_if(InputIterator _First, InputIterator _Last, Predicate _Pred);
10
#include <iostream>
#include <vector>
#include <algorithm>
void main()
{
std::vector<int> V{ 10, 20, 30, 40, 50 };
auto GT25 = [](int n) { return n > 25; };
auto itFI = std::find_if(V.begin(), V.end(), GT25);
if (itFI != V.end())
std::cout << (*itFI) << std::endl;
}
[KOSSA] C++ Programming - 17th Study - STL #3
12
http://www.cplusplus.com/reference/algorithm
13
template<class InputIterator, class Type>
InputIterator remove(InputIterator _First, InputIterator _Last, const Type& _Val);
14
#include <iostream>
#include <vector>
#include <algorithm>
void main()
{
std::vector<int> V{ 10, 20, 30, 40, 50 };
std::cout << "V.size() = " << V.size() << std::endl;
auto itR = std::remove(V.begin(), V.end(), 40);
if (itR != V.end())
{
std::cout << "After remove() : " << V.size() << std::endl;
V.erase(itR, V.end());
std::cout << "After erase() : " << V.size() << std::endl;
}
}
15
template<class InputIterator, class Predicate>
InputIterator remove_if(InputIterator _First, InputIterator _Last, Predicate _Pred);
16
#include <iostream>
#include <vector>
#include <algorithm>
void main()
{
std::vector<int> V{ 10, 15, 30, 45, 50 };
auto isOdd = [](int n) { return n % 2 == 1; };
auto itRI = std::remove_if(V.begin(), V.end(), isOdd);
if (itRI != V.end())
{
std::cout << "After remove_if() : " << V.size() << std::endl;
V.erase(itRI, V.end());
std::cout << "After erase() : " << V.size() << std::endl;
}
}
[KOSSA] C++ Programming - 17th Study - STL #3
18
http://www.cplusplus.com/reference/algorithm
19
template<class RandomAccessIterator, class Pr>
void sort(RandomAccessIterator _First, RandomAccessIterator _Last,
BinaryPredicate _Comp);
20
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
void main()
{
std::vector<int> V{ 10, 30, 15, 50, 45 };
for (auto it = V.begin(); it != V.end(); it++)
std::cout << (*it) << 't';
std::cout << std::endl;
std::sort(V.begin(), V.end(), std::less<int>());
for (auto it = V.begin(); it != V.end(); it++)
std::cout << (*it) << 't';
std::cout << std::endl;
}
21
template<class InputIterator1, class InputIterator2,
class OutputIterator, class BinaryPredicate>
OutputIterator merge(InputIterator1 _First1, InputIterator1 _Last1,
InputIterator2 _First2, InputIterator2 _Last2,
OutputIterator _Result, BinaryPredicate _Comp);
22
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <functional>
void main()
{
std::vector<int> V{ 10, 30, 15, 50, 45 };
std::sort(V.begin(), V.end(), std::less<int>());
std::deque<int> V2{ 13, 78, 57, 24, 69 };
std::sort(V2.begin(), V2.end(), std::less<int>());
std::vector<int> VR;
VR.resize(V.size() + V2.size());
auto isLess = [](int a, int b) { return a < b; };
std::merge(V.begin(), V.end(), V2.begin(), V2.end(), VR.begin(), isLess);
for (auto it = VR.begin(); it != VR.end(); it++)
std::cout << (*it) << 't';
std::cout << std::endl;
}
[KOSSA] C++ Programming - 17th Study - STL #3
24
http://www.cplusplus.com/reference/numeric
25
template<class InputIterator, class Type, class BinaryOperation>
Type accumulate(InputIterator _First, InputIterator _Last,
Type _Val, BinaryOperation _Binary_op);
26
#include <iostream>
#include <vector>
#include <numeric>
void main()
{
std::vector<int> V{ 1, 2, 3, 4};
int nSum = std::accumulate(V.begin(), V.end(), 0); // vector의 합
int nSum10 = std::accumulate(V.begin(), V.end(), 10); // 10 + vector의 합
auto multi = [](int a, int b) { return a * b; };
int nMulti = std::accumulate(V.begin(), V.end(), 1, multi); // 인자의 곱
auto nSqure = [](int a, int b) { return a + b * b; };
int nSumSqure = std::accumulate(V.begin(), V.end(), 0, nSqure); // 제곱의 합
}

More Related Content

PPTX
JavaScript Gotchas
Robert MacLean
 
DOCX
Contraints
Anar Godjaev
 
PDF
New land of error handling in swift
Tsungyu Yu
 
PDF
Python 炒股指南
Leo Zhou
 
PDF
Improving the java type system
João Loff
 
PPTX
3. chapter ii
Chhom Karath
 
DOC
Useful c programs
MD SHAH FAHAD
 
PPTX
4. chapter iii
Chhom Karath
 
JavaScript Gotchas
Robert MacLean
 
Contraints
Anar Godjaev
 
New land of error handling in swift
Tsungyu Yu
 
Python 炒股指南
Leo Zhou
 
Improving the java type system
João Loff
 
3. chapter ii
Chhom Karath
 
Useful c programs
MD SHAH FAHAD
 
4. chapter iii
Chhom Karath
 

What's hot (20)

PDF
VTU DSA Lab Manual
AkhilaaReddy
 
PDF
Python Anti patterns / tips / tricks
rikbyte
 
PDF
Compilation process
Alex Denisov
 
PDF
Introduction to Programming @ NTHUEEECamp 2015
淳佑 楊
 
PDF
2. Базовый синтаксис Java
DEVTYPE
 
DOCX
Catch and throw blocks
ashrafkhan12345
 
PPTX
Exceptional exceptions
Llewellyn Falco
 
PPTX
Session05 iteration structure
HarithaRanasinghe
 
PPTX
4. pointers, arrays
Vahid Heidari
 
PPTX
Namespaces
zindadili
 
PDF
C++ L06-Pointers
Mohammad Shaker
 
PPTX
C Programming Language Step by Step Part 5
Rumman Ansari
 
PDF
Getting started with LLVM using Swift / Алексей Денисов (Blacklane)
Ontico
 
PDF
Print Star pattern in java and print triangle of stars in java
Hiraniahmad
 
PDF
Java script obfuscation
n|u - The Open Security Community
 
PDF
Design patterns in javascript
Abimbola Idowu
 
PPTX
C Programming Language Part 4
Rumman Ansari
 
PDF
05 1 수식과 연산자
Changwon National University
 
PPT
Cquestions
mohamed sikander
 
PDF
C++ L04-Array+String
Mohammad Shaker
 
VTU DSA Lab Manual
AkhilaaReddy
 
Python Anti patterns / tips / tricks
rikbyte
 
Compilation process
Alex Denisov
 
Introduction to Programming @ NTHUEEECamp 2015
淳佑 楊
 
2. Базовый синтаксис Java
DEVTYPE
 
Catch and throw blocks
ashrafkhan12345
 
Exceptional exceptions
Llewellyn Falco
 
Session05 iteration structure
HarithaRanasinghe
 
4. pointers, arrays
Vahid Heidari
 
Namespaces
zindadili
 
C++ L06-Pointers
Mohammad Shaker
 
C Programming Language Step by Step Part 5
Rumman Ansari
 
Getting started with LLVM using Swift / Алексей Денисов (Blacklane)
Ontico
 
Print Star pattern in java and print triangle of stars in java
Hiraniahmad
 
Java script obfuscation
n|u - The Open Security Community
 
Design patterns in javascript
Abimbola Idowu
 
C Programming Language Part 4
Rumman Ansari
 
05 1 수식과 연산자
Changwon National University
 
Cquestions
mohamed sikander
 
C++ L04-Array+String
Mohammad Shaker
 
Ad

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

DOC
Oops lab manual2
Mouna Guru
 
PPTX
Add an interactive command line to your C++ application
Daniele Pallastrelli
 
PDF
An Introduction to Part of C++ STL
乐群 陈
 
PPT
Евгений Крутько, Многопоточные вычисления, современный подход.
Platonov Sergey
 
KEY
Matuura cpp
matuura_core
 
PPTX
C++ Code as Seen by a Hypercritical Reviewer
Andrey Karpov
 
PDF
include ltiostreamgt include ltstringgt include .pdf
contact32
 
TXT
C code
UET Taxila
 
PDF
Java agents are watching your ByteCode
Roman Tsypuk
 
PDF
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019
corehard_by
 
PDF
C++ extension methods
phil_nash
 
PDF
Modern C++ Concurrency API
Seok-joon Yun
 
PPTX
C++11 - A Change in Style - v2.0
Yaser Zhian
 
PPT
Whats new in_csharp4
Abed Bukhari
 
PPTX
Making Java more dynamic: runtime code generation for the JVM
Rafael Winterhalter
 
PDF
Welcome to Modern C++
Seok-joon Yun
 
PDF
Moony li pacsec-1.8
PacSecJP
 
PDF
Riga Dev Day 2016 - Having fun with Javassist
Anton Arhipov
 
PDF
C++ Programming - 1st Study
Chris Ohk
 
Oops lab manual2
Mouna Guru
 
Add an interactive command line to your C++ application
Daniele Pallastrelli
 
An Introduction to Part of C++ STL
乐群 陈
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Platonov Sergey
 
Matuura cpp
matuura_core
 
C++ Code as Seen by a Hypercritical Reviewer
Andrey Karpov
 
include ltiostreamgt include ltstringgt include .pdf
contact32
 
C code
UET Taxila
 
Java agents are watching your ByteCode
Roman Tsypuk
 
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019
corehard_by
 
C++ extension methods
phil_nash
 
Modern C++ Concurrency API
Seok-joon Yun
 
C++11 - A Change in Style - v2.0
Yaser Zhian
 
Whats new in_csharp4
Abed Bukhari
 
Making Java more dynamic: runtime code generation for the JVM
Rafael Winterhalter
 
Welcome to Modern C++
Seok-joon Yun
 
Moony li pacsec-1.8
PacSecJP
 
Riga Dev Day 2016 - Having fun with Javassist
Anton Arhipov
 
C++ Programming - 1st Study
Chris Ohk
 
Ad

More from Seok-joon Yun (20)

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

Recently uploaded (20)

PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PDF
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
Exploring AI Agents in Process Industries
amoreira6
 
PDF
An Experience-Based Look at AI Lead Generation Pricing, Features & B2B Results
Thomas albart
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PDF
Immersive experiences: what Pharo users do!
ESUG
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Exploring AI Agents in Process Industries
amoreira6
 
An Experience-Based Look at AI Lead Generation Pricing, Features & B2B Results
Thomas albart
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
Immersive experiences: what Pharo users do!
ESUG
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 

[KOSSA] C++ Programming - 17th Study - STL #3