Turbo-C
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
터보-C 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
Lua 게시판
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C/C++ 팁&트릭
[26] [STL]adjacent_find 알고리듬
김백일 [cedar] 3208 읽음    2002-06-27 13:58
adjacent_find 알고리듬은 시퀀스에서 동일한 원소가 이웃하고 있는 쌍을 찾아, 앞쪽 원소를 가리키는 반복자를 리턴합니다.

다음은 예제 코드입니다.

// Illustrating the generic adjacent_find algorithm
#include <cassert>
#pragma hdrstop
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
  string *i, player[5] = {"Pele", "Platini", "Maradona", "Maradona", "Rossi"};

  // Find the first pair of equal consecutive names:
  i = adjacent_find(player, player + 5);
  assert (*i == "Maradona" && *(i+1) == "Maradona");

  // Find the first name that is lexicographically
  // greater than the following name:
  i = adjacent_find(player, player + 5, greater<string>());
  assert (*i == "Platini" && *(i+1) == "Maradona");

  return 0;
}

+ -

관련 글 리스트
26 [STL]adjacent_find 알고리듬 김백일 3208 2002/06/27
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.