Notice
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- Deque
- Visual Micro
- priority_queue
- LineTracer
- Algorithm
- set
- 라인트레이서
- 아두이노 소스
- stl
- WinAPI
- 아두이노
- 컴퓨터 그래픽스
- 자료구조
- directx
- vector
- Array
- 시스템프로그래밍
- Arduino
- queue
- map
- 아두이노 컴파일러
- html
- list
- 운영체제
- c++
- 통계학
- 수광 소자
- arduino compiler
- Stack
- C언어
Archives
- Today
- Total
Kim's Programming
List - resize() 본문
소스)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include<list> #include<iostream> void print(std::list<int> Target_List) { for (std::list<int>::iterator IterPos = Target_List.begin(); IterPos != Target_List.end(); ++IterPos) std::cout << *IterPos << " "; std::cout << std::endl; } void main() { std::list<int> List = { 1,2,3,4,100,101,102,103,100 }; print(List); List.resize(3); print(List); List.resize(5, 15); print(List); } | cs |
내용)
resize() 함수는 리스트의 크기를 조정합니다. 파라메터에 따라 2가지 기능을 합니다.
- resize(x)
list의 데이터 갯수를 앞에서 부터 x개 만큼만 남기고 삭제합니다. - resize(x,y)
list의 데이터 갯수를 x개로 변경시키되 만약 현재 사이즈보다 x가 더 클 경우 그 부분에 대해서 y로 채웁니다.
결과)
'STL - Container > Container - List' 카테고리의 다른 글
| List - size() (0) | 2016.01.29 |
|---|---|
| List - reverse() (0) | 2016.01.29 |
| List - rend() (0) | 2016.01.29 |
| List - remove_if() (0) | 2016.01.29 |
| List - remove() (0) | 2016.01.29 |