이름공간
변수
행위

"cpp/iterator"의 두 판 사이의 차이

cppreference.com
< cpp
(translate to korean)
 
(한 사용자의 중간의 편집 1개 숨겨짐)
2번째 줄: 2번째 줄:
 
{{cpp/iterator/navbar}}
 
{{cpp/iterator/navbar}}
  
반복자(iterator) 라이브러리는 다섯가지 종류의 반복자 뿐만아니라 반복자 특징, 어뎁터, 유틸리티 함수를 제공합니다.
+
반복자(iterator) 라이브러리는 종류의 반복자 뿐만아니라 반복자 특징, 어뎁터, 유틸리티 함수를 제공합니다.
  
 
===Iterator categories===
 
===Iterator categories===
  
다섯가지 종류의 반복자 : {{concept|InputIterator}}, {{concept|OutputIterator}}, {{concept|ForwardIterator}}, {{concept|BidirectionalIterator}}, {{concept|RandomAccessIterator}}.
+
반복자 : {{concept|}}, {{concept|}}, {{concept|}}, {{concept|}}, {{concept|}}
  
  
각 카테고리는 특정 타입에 의해 정의되는 것이 아니라 각 반복자가 어떻게 동작하느냐로 정의됩니다. 이 정의는 타입별로 필요한 동작을 수행하는 반복자를 사용할 수 있다는 것입니다. -- 예를들어, 포인터는 {{concept|RandomAccessIterator}}의 모든 요구사항을 지원하기 때문에 {{concept|RandomAccessIterator}}가 필요한 모든 곳에서 포인터가 사용될 수 있습니다.
+
각 카테고리는 특정 타입에 의해 정의되는 것이 아니라 각 반복자가 어떻게 동작하느냐로 정의됩니다. 이 정의는 타입별로 필요한 동작을 수행하는 반복자를 사용할 수 있다는 것입니다. -- 예를들어, 포인터는 {{concept|}}의 모든 요구사항을 지원하기 때문에 {{concept|}}가 필요한 모든 곳에서 포인터가 사용될 수 있습니다.
  
 
+
반복자 카테고리는 계층적으로 구분할 수 있으며 최상위 반복자(예를들어 {{concept|}})는 하위 반복자(예를들어 {{concept|}})의 기능을 포함합니다. 만약 반복자가 이 카테고리중 하나에 속하면 {{concept|}}의 요구사항을 만족해야 합니다. 그리고 이는 ''mutable'' 반복자라 부르고 입,출력을 모두 지원합니다. Non-mutable 반복자는 ''constant'' 반복자라고 부릅니다.
다섯가지 중 네가지 반복자 카테고리는 계층적으로 구분할 수 있으며, 최상위 반복자(예를들어 {{concept|RandomAccessIterator}})는 하위 반복자(예를들어 {{concept|InputIterator}})의 기능을 포함합니다. 만약 반복자가 이 카테고리중 하나에 속하면 {{concept|OutputIterator}}의 요구사항을 만족해야 합니다. 그리고 이는 ''mutable'' 반복자라 부르고 입,출력을 모두 지원합니다. Non-mutable 반복자는 ''constant'' 반복자라고 부릅니다.
+
  
  
19번째 줄: 18번째 줄:
 
!Defined operations
 
!Defined operations
 
|-
 
|-
|rowspan="4"|{{concept|RandomAccessIterator}}
+
|rowspan="4"|{{concept|}}
|rowspan="3"|{{concept|BidirectionalIterator}}
+
|rowspan="3"|{{concept|}}
|rowspan="2"|{{concept|ForwardIterator}}
+
|rowspan="2"|{{concept|}}
|{{concept|InputIterator}}
+
|{{concept|}}
 
|  
 
|  
* read
+
*
* increment (without multiple passes)
+
* (without multiple passes)
 
|-
 
|-
 
|
 
|
 
|
 
|
* increment (with multiple passes)
+
* (with multiple passes)
 
|-
 
|-
 
|colspan="2"|
 
|colspan="2"|
40번째 줄: 39번째 줄:
 
|-
 
|-
 
| colspan="5" style="text-align:center;" |
 
| colspan="5" style="text-align:center;" |
Iterators that fall into one of the above categories and also meet the requirements of {{concept|OutputIterator}} are called mutable iterators.
+
Iterators that fall into one of the above categories and also meet the requirements of {{concept|}} are called mutable iterators.
 
|-
 
|-
|{{concept|OutputIterator}}
+
|{{concept|}}
 
|colspan="3"|
 
|colspan="3"|
 
|
 
|
 
* write
 
* write
 
* increment (without multiple passes)
 
* increment (without multiple passes)
 +
 +
 +
 +
 +
 +
 +
 +
 
|}
 
|}
  

2019년 4월 22일 (월) 18:53 기준 최신판

반복자(iterator) 라이브러리는 5가지(c++17 이전) 혹은 6가지(c++17 이후) 종류의 반복자 뿐만아니라 반복자 특징, 어뎁터, 유틸리티 함수를 제공합니다.

목차

[편집] Iterator categories

반복자 : LegacyInputIterator, LegacyOutputIterator, LegacyForwardIterator, LegacyBidirectionalIterator, LegacyRandomAccessIterator, LegacyContiguousIterator


각 카테고리는 특정 타입에 의해 정의되는 것이 아니라 각 반복자가 어떻게 동작하느냐로 정의됩니다. 이 정의는 타입별로 필요한 동작을 수행하는 반복자를 사용할 수 있다는 것입니다. -- 예를들어, 포인터는 LegacyRandomAccessIterator의 모든 요구사항을 지원하기 때문에 LegacyRandomAccessIterator가 필요한 모든 곳에서 포인터가 사용될 수 있습니다.

OutputInteratorLegacyContiguousIterator를 제외하고 모든 반복자 카테고리는 계층적으로 구분할 수 있으며 최상위 반복자(예를들어 LegacyRandomAccessIterator)는 하위 반복자(예를들어 LegacyInputIterator)의 기능을 포함합니다. 만약 반복자가 이 카테고리중 하나에 속하면 LegacyOutputIterator의 요구사항을 만족해야 합니다. 그리고 이는 mutable 반복자라 부르고 입,출력을 모두 지원합니다. Non-mutable 반복자는 constant 반복자라고 부릅니다.


Iterator category Defined operations
LegacyRandomAccessIterator LegacyBidirectionalIterator LegacyForwardIterator LegacyInputIterator
  • 읽기
  • 증가연산 (without multiple passes)
  • 증가연산 (with multiple passes)
  • decrement
  • random access

Iterators that fall into one of the above categories and also meet the requirements of LegacyOutputIterator are called mutable iterators.

LegacyOutputIterator
  • write
  • increment (without multiple passes)

Iterators that fall into one of the above categories and also meet the requirements of LegacyContiguousIterator are called contiguous iterators.

LegacyContiguousIterator
  • contiguous storage

[편집] Iterator primitives

provides uniform interface to the properties of an iterator
(class template) [edit]
empty class types used to indicate iterator categories
(class) [edit]
the basic iterator
(class template) [edit]

[편집] Iterator adaptors

iterator adaptor for reverse-order traversal
(class template) [edit]
iterator adaptor which dereferences to an rvalue reference
(class template) [edit]
creates a std::move_iterator of type inferred from the argument
(function template) [edit]
iterator adaptor for insertion at the end of a container
(class template) [edit]
creates a std::back_insert_iterator of type inferred from the argument
(function template) [edit]
iterator adaptor for insertion at the front of a container
(class template) [edit]
creates a std::front_insert_iterator of type inferred from the argument
(function template) [edit]
iterator adaptor for insertion into a container
(class template) [edit]
creates a std::insert_iterator of type inferred from the argument
(function template) [edit]

[편집] Stream iterators

input iterator that reads from std::basic_istream
(class template) [edit]
output iterator that writes to std::basic_ostream
(class template) [edit]
input iterator that reads from std::basic_streambuf
(class template) [edit]
output iterator that writes to std::basic_streambuf
(class template) [edit]

[편집] Iterator operations

<iterator> 헤더에 정의됨.
advances an iterator by given distance
(function) [edit]
returns the distance between two iterators
(function) [edit]
(C++11)
increment an iterator
(function) [edit]
(C++11)
decrement an iterator
(function) [edit]

[편집] Range access

<iterator> 헤더에 정의됨.
(C++11)
(C++14)
returns an iterator to the beginning of a container or array
(function) [edit]
(C++11)
(C++14)
returns an iterator to the end of a container or array
(function) [edit]
returns a reverse iterator to a container or array
(function) [edit]
(C++14)
returns a reverse end iterator for a container or array
(function) [edit]