본문 바로가기

Programming

How to find if vector contains specific value or not in C++, 씨쁠쁠 stl 벡터에 특정 값이 이미 있는지 확인하는 방법

 

How to find if vector contains specific value or not in C++, 씨쁠쁠 stl 벡터에 특정 값이 이미 있는지 확인하는 방법

 

 

std::find 함수를 써서 vector 의 시작부터 끝까지 확인해서 확인한다.

 

We can check if it has specific value using std::find function iterate from begin to the end.

 

 

 

    
    if (find(targetVector.begin(), targetVector.end(), value) != targetVector.end()) {
		// it has the value
	}
	else {
		// it doesn't have that value
	}
    

 

 

 

2019/03/01 - [Programming/C++] - Basic C++ project setting process C++(Console, MFC, GUI) 프로젝트 기본 설정 (Console, MFC, GUI), visual studio, console wait

2019/02/24 - [Programming/C++] - How to use bitset, bitwise operator in c++, 비트셋, 비트연산자 사용하는 방법, 이진수 변환 방법, How to convert decimal to binary, binary to decimal

2019/02/17 - [Programming/C++] - How to add/insert char in front of string in c++, 스트링 문자 앞에 char문자 캐릭터 추가하는 방법, 예제, example code, java

2019/02/12 - [Programming/C++] - How to use map in c++ STL, c++ 맵 STL 사용방법/초기화/예제, java, example, sample, library, find, insert, first

 

 

2019/01/29 - [Programming/Programming Language] - 클린코딩/더 나은 코딩을 하는 10가지 방법, 10 Tips for clean code/ better code/ quality code.

 

2019/01/30 - [Programming/Software Architecture] - What is Object Oriented Design/Artchitecture? 객체지향 디자인/설계란? java,c++,softwareArchitecture,designPattern

 

 

2018/12/28 - [Programming/Software Architecture] - Perfecting OO's Small Classes and Short Methods. 완벽한 객체지향의 작은 클래스와 짧은 메소드, Book:ThoughtWorks Anthology, Java,cpp,자바,oop,좋은코드,객체지향프로그래밍 - (#9, Tell, Don't Ask)

2018/12/26 - [Programming/Software Architecture] - Perfecting OO's Small Classes and Short Methods. 완벽한 객체지향의 작은 클래스와 짧은 메소드, Book:ThoughtWorks Anthology, Java,cpp,자바,oop,좋은코드,객체지향프로그래밍 (1)

 

 

2019/01/12 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #60 sudoku. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive

2019/01/12 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #59 spiralNumbers. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive

 

2019/02/01 - [Algorithm/Leet Code] - LeetCode #905 SortArrayByParity. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접

2019/02/03 - [Algorithm/Leet Code] - LeetCode #398 RandomPickIndex. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접

2019/01/27 - [Algorithm/Leet Code] - LeetCode #204 CountPrimes. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접,소수판별,에..

2019/01/24 - [Algorithm/Leet Code] - LeetCode #242 ValidAnagram. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접