이름공간
변수
행위

std::forward_list

cppreference.com
< cpp‎ | container
 
 
 
 
<forward_list> 에 정의되어 있음.
template<

    class T,
    class Allocator = std::allocator<T>

> class forward_list;
(since C++11)

std::forward_list는 어느 위치에서나 빠른 삽입 삭제를 지원 하는 컨테이너 이다. 임의의 위치로의 접근은 느리다. 단일연결리스트(singly-linked list)로 구현되었고 동일한 C 언어 구현에 비해서 본질적인 부하는 없다. std::list와 비교해보면 이 컨테이너는 양방향 접근이 필요없을 때에 더욱 공간 효율적인 저장소이다.

또한 리스트 내나 리스트 간의 특정 값(element)의 삭제나 이동은 리스트의 다른 값의 반복자(iterator)에는 영향을 주지 않는다. 그러나 해당 값의 반복자나 참조는 해당 값이 리스트에서 삭제(erase_after를 통해)될 때에 무효화된다.

std::forward_listContainer(size() 맴버 함수와 operator== 의 복잡도가 항상 선형적이어야 한다는 것을 제외하고), AllocatorAwareContainer, SequenceContainer의 요구사항을 만족한다.

목차

[편집] Template parameters

T - 원소의 타입.
TCopyAssignableCopyConstructible 의 요구 조건을 만족시켜야 한다. (until C++11)
원소가 만족시켜야 하는 조건들은 컨테이너에서 행해지는 실제 작업들에 의존한다. 일반적으로, 원소 형은 MoveConstructibleMoveAssignable 의 요구 조건을 만족시켜야 하나, 대부분의 멤버 함수들은 더 많은 조건을 요구한다. (since C++11)

[edit]

Allocator - 원소들을 저장하기 위해 메모리를 얻기 위해 쓰이는 할당자(allocator)이다. 이 형은 Allocator 의 요구 조건을 만족시켜야 한다. [edit]

[편집] Member types

Member type Definition
value_type T [edit]
allocator_type 할당자 [edit]
size_type 부호 없는 정수(unsigned int) 타입 (일반적으로 std::size_t) [edit]
difference_type 부호 있는 정수(signed int) 타입 (보통 std::ptrdiff_t) [edit]
reference value_type& [edit]
const_reference const value_type& [edit]
pointer std::allocator_traits<Allocator>::pointer [edit]
const_pointer std::allocator_traits<Allocator>::const_pointer [edit]
iterator ForwardIterator [edit]
const_iterator 상수(constant) 양방향 반복자(iterator) [edit]

[편집] Member functions

forward_list의 생성자이다.
(public member function) [edit]
forward_list의 소멸자이다.
(public member function) [edit]
컨테이너에 값을 할당한다.
(public member function) [edit]
컨테이너에 값을 할당한다.
(public member function) [edit]
연관된 할당자를 반환한다.
(public member function) [edit]
Element access
첫번째 요소에 접근한다.
(public member function) [edit]
Iterators
returns an iterator to the element before beginning
(public member function) [edit]
첫번째 원소로의 반복자(iterator)를 반환한다.
(public member function) [edit]
마지막 원소로의 반복자(iterator)를 반환한다.
(public member function) [edit]
Capacity
현재 컨테이너가 비어있는지 확인한다.
(public member function) [edit]
원소의 최대 개수를 반환한다.
(public member function) [edit]
Modifiers
내용물을 모두 지운다.
(public member function) [edit]
inserts elements after an element
(public member function) [edit]
constructs elements in-place after an element
(public member function) [edit]
erases an element after an element
(public member function) [edit]
새로운 원소를 앞에 삽입한다
(public member function) [edit]
constructs elements in-place at the beginning
(public member function) [edit]
첫번째 원소를 없앤다
(public member function) [edit]
원소의 총 갯수를 바꾼다
(public member function) [edit]
원소들을 서로 바꾼다
(public member function) [edit]
Operations
merges two sorted lists
(public member function) [edit]
moves elements from another forward_list
(public member function) [edit]
removes elements satisfying specific criteria
(public member function) [edit]
reverses the order of the elements
(public member function) [edit]
removes consecutive duplicate elements
(public member function) [edit]
sorts the elements
(public member function) [edit]

[편집] Non-member functions

lexicographically compares the values in the forward_list
(function template) [edit]
specializes the std::swap algorithm
(function template) [edit]