--- id: cpp-data-structures title: "C++ Data Structures and STL" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["STL", "Standard Template Library", "C++ 자료ꡬ쑰"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.87 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["cpp", "programming-language", "w3schools", "stl", "data-structures"] raw_sources: ["https://www.w3schools.com/cpp/cpp_data_structures.asp"] applied_in: [] github_commit: "" --- # [[CPP Data Structures]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) C has exactly ONE built-in data structure β€” the array β€” and everything else (linked lists, stacks, queues, hash-like maps) must be hand-built from structs and raw pointers; C++'s STL instead ships vector/list/stack/queue/deque/set/map as ready-made template classes, meaning the entire "how do I build a linked list" problem that consumed a whole chapter of Topic_C's Pointers section is simply gone from the C++ mental model β€” replaced by "which header do I include." [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **STL (Standard Template Library)** β€” a library of data structures + algorithms bundled with C++, used to store and manipulate data efficiently. [S1] - **Containers** β€” data structures that store data (vector, list, stack, queue, deque, set, map). [S1] - **Iterators** β€” objects used to access elements of a container without knowing its internal layout. [S1] - **Algorithms** β€” functions like `sort()` and `find()` that operate on containers through iterators. [S1] - **One header per container** β€” each container requires its own `#include` (``, ``, ``, ``, ``, ``), unlike arrays which need no header. [S1] - **Choosing a container is a design decision** β€” the right data structure + algorithm makes a program run faster, especially at scale; the table of 7 containers (Vector/List/Stack/Queue/Deque/Set/Map) each optimize a different access pattern. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Container comparison table: Vector (array-like, dynamic size, index access), List (sequential, add/remove both ends, no index access), Stack (LIFO, top only), Queue (FIFO, front/back only), Deque (double-ended, index access), Set (unique elements, no index), Map (key/value pairs, access by key). [S1] - Minimal vector usage: `vector cars = {"Volvo", "BMW", "Ford", "Mazda"}; for (string car : cars) { cout << car << "\n"; }`. [S1] - Containers + iterators + algorithms form a triangle: a container without an algorithm to search/manipulate it is not very useful, and an algorithm needs a container to operate on. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **Cμ—λŠ” μ—†λŠ” κ°œλ… μΈ΅μœ„κ°€ ν†΅μ§Έλ‘œ 좔가됨**: Topic_Cμ—λŠ” "자료ꡬ쑰 챕터"κ°€ μ‘΄μž¬ν•˜μ§€ μ•Šμ•˜κ³ (배열이 μœ μΌν•œ λ‚΄μž₯ 자료ꡬ쑰), μ—°κ²° 리슀트/μŠ€νƒ/νλŠ” 포인터+ꡬ쑰체둜 직접 κ΅¬ν˜„ν•˜λŠ” μ˜ˆμ œλ“€μ΄ Pointers μ„Ήμ…˜μ— 흩어져 μžˆμ—ˆλ‹€. C++λŠ” 이λ₯Ό μ»¨ν…Œμ΄λ„ˆ+반볡자+μ•Œκ³ λ¦¬μ¦˜μ΄λΌλŠ” 3μΈ΅ ꡬ쑰둜 λΌμ΄λΈŒλŸ¬λ¦¬ν™”ν–ˆλ‹€λŠ” 점이 이번 μ±•ν„°μ—μ„œ λͺ…ν™•νžˆ λ“œλŸ¬λ‚¨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” λ¬Έμžμ—΄ vectorλ₯Ό λ§Œλ“€κ³  for-each둜 μˆœνšŒν•˜λŠ” νŒ¨ν„΄μ΄ μ›λ¬Έμ—μ„œ STL μ†Œκ°œ 예제둜 μ œμ‹œλ¨. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Required headers per container, and a first vector example (C++): ```cpp #include #include #include #include #include #include vector cars = {"Volvo", "BMW", "Ford", "Mazda"}; for (string car : cars) { cout << car << "\n"; } ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.87 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[C++ Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CPP Vectors]], [[CPP List]], [[CPP Stacks]], [[CPP Queues]], [[CPP Arrays]] - **μ°Έμ‘° λ§₯락:** 데이터 ꡬ쑰(STL) μ„Ήμ…˜μ˜ λ„μž… 챕터 β€” Vectors둜 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” C++ Data Structures and STL β€” https://www.w3schools.com/cpp/cpp_data_structures.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C++ Data Structures and STL" page (Astra wiki-curation, P-Reinforce v3.1 format).