1cfd3bbb56
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
4.5 KiB
4.5 KiB
id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
| id | title | category | status | verification_status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | created_at | updated_at | review_reason | merge_history | tags | raw_sources | applied_in | github_commit | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cpp-list | C++ List | Programming_Language | draft | conceptual |
|
B | 0.86 | 2026-07-04 | 2026-07-04 |
|
|
CPP List
🎯 한 줄 통찰 (One-line insight)
list is the STL container that most directly replaces what C programmers had to hand-build with struct Node { int data; Node* next; } — a linked list that grows anywhere and adds/removes at both ends cheaply — but in exchange for that flexibility it gives up random-access indexing entirely (no list[i]), so choosing between vector and list is choosing between C-array-like index speed versus C-linked-list-like two-ended growth, expressed here as a one-line design decision instead of a whole custom data structure. [S1]
🧠 핵심 개념 (Core concepts)
list<type> name— declared like a vector, e.g.list<string> cars;, requires<list>. [S1]- No index access — unlike vector, elements cannot be retrieved by
[i]or.at(i); only.front()and.back()are available. [S1] - Both-ends growth —
.push_front()/.push_back()add at the beginning/end;.pop_front()/.pop_back()remove from the beginning/end — vectors only optimize the "back" side. [S1] .front()/.back()are also mutable — assigning tocars.front() = "Opel"changes the first element directly, since there's no index-based assignment. [S1]- Looping restriction — a traditional indexed
forloop combined with.size()does NOT work for lists (nocars[i]); only a for-each loop (or, later, an iterator) can traverse a list. [S1] .size()/.empty()— same semantics as vector. [S1]
📖 세부 내용 (Details)
- Declaration with initial values:
list<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};. [S1] - Add:
cars.push_front("Tesla"); cars.push_back("VW");. [S1] - Remove:
cars.pop_front(); cars.pop_back();. [S1] - The page explicitly shows the broken indexed-loop attempt (
for (int i = 0; i < cars.size(); i++) { cout << cars[i]; }) as something that will NOT compile, then gives the working for-each replacement. [S1]
⚖️ 모순 및 업데이트 (Contradictions & updates)
- 인덱스 접근 자체가 존재하지 않음: vector는 배열처럼 인덱스 접근이 가능했지만, list는 순차 연결 구조이기 때문에 인덱스 접근 자체가 언어 차원에서 불가능하다는 점이 이번 챕터에서 vector와의 핵심 차이로 명시됨. [S1]
- 양쪽 끝 삽입/삭제가 대칭적으로 지원됨: vector는 뒤쪽(push_back/pop_back)에만 최적화되어 있었지만, list는 앞/뒤 양쪽 모두 push_front/pop_front, push_back/pop_back으로 대칭적으로 지원한다는 점이 vector와 대비됨. [S1]
🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — 자동차 이름 리스트의 양 끝에 원소를 추가/삭제하는 예제가 원문에서 제시됨. [S1]
💻 코드 패턴 (Code patterns)
List-specific operations unavailable on vector — both-ends push/pop (C++):
#include <list>
list<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};
cars.push_front("Tesla"); // add at beginning
cars.push_back("VW"); // add at end
cars.pop_front(); // remove from beginning
cars.pop_back(); // remove from end
// No index access — must use for-each:
for (string car : cars) {
cout << car << "\n";
}
✅ 검증 상태 및 신뢰도
- 상태: draft
- 검증 단계: conceptual
- 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
- 신뢰 점수: 0.86
- 중복 검사 결과: 신규 생성 (New discovery)
🔗 지식 그래프 (Knowledge Graph)
- 상위/루트: C++ Tutorial
- 관련 개념: CPP Vectors, CPP Stacks, CPP Data Structures, C Pointers
- 참조 맥락: 데이터 구조(STL) 섹션 — Stacks 챕터로 이어짐.
📚 출처 (Sources)
- [S1] W3Schools — C++ List — https://www.w3schools.com/cpp/cpp_list.asp
📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ List" page (Astra wiki-curation, P-Reinforce v3.1 format).