std::forward_list
cppreference.com
<forward_list> 에 정의되어 있음.
|
||
template< class T, |
(since C++11) | |
std::forward_list
는 어느 위치에서나 빠른 삽입 삭제를 지원 하는 컨테이너 이다. 임의의 위치로의 접근은 느리다. 단일연결리스트(singly-linked list)로 구현되었고 동일한 C 언어 구현에 비해서 본질적인 부하는 없다. std::list와 비교해보면 이 컨테이너는 양방향 접근이 필요없을 때에 더욱 공간 효율적인 저장소이다.
또한 리스트 내나 리스트 간의 특정 값(element)의 삭제나 이동은 리스트의 다른 값의 반복자(iterator)에는 영향을 주지 않는다. 그러나 해당 값의 반복자나 참조는 해당 값이 리스트에서 삭제(erase_after를 통해)될 때에 무효화된다.
std::forward_list
는 Container
(size() 맴버 함수와 operator==
의 복잡도가 항상 선형적이어야 한다는 것을 제외하고), AllocatorAwareContainer
, SequenceContainer
의 요구사항을 만족한다.
목차 |
[편집] Template parameters
T | - | 원소의 타입.
| ||||
Allocator | - | 원소들을 저장하기 위해 메모리를 얻기 위해 쓰이는 할당자(allocator)이다. 이 형은 Allocator 의 요구 조건을 만족시켜야 한다.
|
[편집] Member types
Member type | Definition |
value_type
|
T
|
allocator_type
|
할당자
|
size_type
|
부호 없는 정수(unsigned int) 타입 (일반적으로 std::size_t) |
difference_type
|
부호 있는 정수(signed int) 타입 (보통 std::ptrdiff_t) |
reference
|
value_type&
|
const_reference
|
const value_type&
|
pointer
|
std::allocator_traits<Allocator>::pointer |
const_pointer
|
std::allocator_traits<Allocator>::const_pointer |
iterator
|
ForwardIterator
|
const_iterator
|
상수(constant) 양방향 반복자(iterator) |
[편집] Member functions
forward_list 의 생성자이다. (public member function) | |
forward_list 의 소멸자이다. (public member function) | |
컨테이너에 값을 할당한다. (public member function) | |
컨테이너에 값을 할당한다. (public member function) | |
연관된 할당자를 반환한다. (public member function) | |
Element access | |
첫번째 요소에 접근한다. (public member function) | |
Iterators | |
returns an iterator to the element before beginning (public member function) | |
첫번째 원소로의 반복자(iterator)를 반환한다. (public member function) | |
마지막 원소로의 반복자(iterator)를 반환한다. (public member function) | |
Capacity | |
현재 컨테이너가 비어있는지 확인한다. (public member function) | |
원소의 최대 개수를 반환한다. (public member function) | |
Modifiers | |
내용물을 모두 지운다. (public member function) | |
inserts elements after an element (public member function) | |
constructs elements in-place after an element (public member function) | |
erases an element after an element (public member function) | |
새로운 원소를 앞에 삽입한다 (public member function) | |
constructs elements in-place at the beginning (public member function) | |
첫번째 원소를 없앤다 (public member function) | |
원소의 총 갯수를 바꾼다 (public member function) | |
원소들을 서로 바꾼다 (public member function) | |
Operations | |
merges two sorted lists (public member function) | |
moves elements from another forward_list (public member function) | |
removes elements satisfying specific criteria (public member function) | |
reverses the order of the elements (public member function) | |
removes consecutive duplicate elements (public member function) | |
sorts the elements (public member function) |
[편집] Non-member functions
lexicographically compares the values in the forward_list (function template) | |
specializes the std::swap algorithm (function template) |