Table of Contents

CPP <list>

(TrCppBS 2022)

header <list> List header Header that defines the list container class:

Classes list List (class template)

Functions begin Iterator to beginning (function template) end Iterator to end (function template)

https://cplusplus.com/reference/list/

class template <list> std::list template < class T, class Alloc = allocator<T> > class list; List Lists are sequence containers that allow constant time insert and erase operations anywhere within the sequence, and iteration in both directions.

List containers are implemented as doubly-linked lists; Doubly linked lists can store each of the elements they contain in different and unrelated storage locations. The ordering is kept internally by the association to each element of a link to the element preceding it and a link to the element following it.

They are very similar to forward_list: The main difference being that forward_list objects are single-linked lists, and thus they can only be iterated forwards, in exchange for being somewhat smaller and more efficient.

Compared to other base standard sequence containers (array, vector and deque), lists perform generally better in inserting, extracting and moving elements in any position within the container for which an iterator has already been obtained, and therefore also in algorithms that make intensive use of these, like sorting algorithms.

The main drawback of lists and forward_lists compared to these other sequence containers is that they lack direct access to the elements by their position; For example, to access the sixth element in a list, one has to iterate from a known position (like the beginning or the end) to that position, which takes linear time in the distance between these. They also consume some extra memory to keep the linking information associated to each element (which may be an important factor for large lists of small-sized elements).

Container properties Sequence Elements in sequence containers are ordered in a strict linear sequence. Individual elements are accessed by their position in this sequence. Doubly-linked list Each element keeps information on how to locate the next and the previous elements, allowing constant time insert and erase operations before or after a specific element (even of entire ranges), but no direct random access. Allocator-aware The container uses an allocator object to dynamically handle its storage needs.

Template parameters T Type of the elements. Aliased as member type list::value_type. Alloc Type of the allocator object used to define the storage allocation model. By default, the allocator class template is used, which defines the simplest memory allocation model and is value-independent. Aliased as member type list::allocator_type.

Member types C++98C++11 member type definition notes value_type The first template parameter (T) allocator_type The second template parameter (Alloc) defaults to: allocator<value_type> reference allocator_type::reference for the default allocator: value_type& const_reference allocator_type::const_reference for the default allocator: const value_type& pointer allocator_type::pointer for the default allocator: value_type* const_pointer allocator_type::const_pointer for the default allocator: const value_type* iterator a bidirectional iterator to value_type convertible to const_iterator const_iterator a bidirectional iterator to const value_type reverse_iterator reverse_iterator<iterator> const_reverse_iterator reverse_iterator<const_iterator> difference_type a signed integral type, identical to: iterator_traits<iterator>::difference_type usually the same as ptrdiff_t size_type an unsigned integral type that can represent any non-negative value of difference_type usually the same as size_t

Member functions (constructor) Construct list (public member function) (destructor) List destructor (public member function) operator= Assign content (public member function)

Iterators: begin Return iterator to beginning (public member function) end Return iterator to end (public member function) rbegin Return reverse iterator to reverse beginning (public member function) rend Return reverse iterator to reverse end (public member function) cbegin Return const_iterator to beginning (public member function) cend Return const_iterator to end (public member function) crbegin Return const_reverse_iterator to reverse beginning (public member function) crend Return const_reverse_iterator to reverse end (public member function)

Capacity: empty Test whether container is empty (public member function) size Return size (public member function) max_size Return maximum size (public member function)

Element access: front Access first element (public member function) back Access last element (public member function)

Modifiers: assign Assign new content to container (public member function) emplace_front Construct and insert element at beginning (public member function) push_front Insert element at beginning (public member function) pop_front Delete first element (public member function) emplace_back Construct and insert element at the end (public member function) push_back Add element at the end (public member function) pop_back Delete last element (public member function) emplace Construct and insert element (public member function) insert Insert elements (public member function) erase Erase elements (public member function) swap Swap content (public member function) resize Change size (public member function) clear Clear content (public member function)

Operations: splice Transfer elements from list to list (public member function) remove Remove elements with specific value (public member function) remove_if Remove elements fulfilling condition (public member function template) unique Remove duplicate values (public member function) merge Merge sorted lists (public member function) sort Sort elements in container (public member function) reverse Reverse the order of elements (public member function)

Observers: get_allocator Get allocator (public member function)

Non-member function overloads relational operators (list) Relational operators for list (function) swap (list) Exchanges the contents of two lists (function template)

https://cplusplus.com/reference/list/list/

CPP

Return to Tour of C++, 3rd Edition by Bjarne Stroustrup, C++ Fundamentals, C++ Bibliography - C++ People, C++, C++ DevOps - C++ SRE - C++ CI/CD, Cloud Native C++ - C++ Microservices - Serverless C++, C++ Security - C++ DevSecOps, Functional C++, C++ Concurrency, C++ Data Science - C++ and Databases, C++ Machine Learning, C++ Courses, C++ Glossary, Awesome C++, C++ GitHub, C++ Topics

Fair Use Source: B0B8S35JWV, (TrCppBS 2022)

“ (TrCppBS 2022)

Fair Use Sources

Fair Use Sources:

C++ Containers: C++ Core Guidelines for Containers, Containers

array, vector, deque, list, forward_list, set, multiset, map, multimap, unordered_set, unordered_multiset, unordered_map, unordered_multimap, stack, queue, priority_queue, span, string, wstring, u16string, u32string, bitset, valarray, tuple, pair, optional, variant, any, bitset, buffer, circular_buffer, slist, rope, splay_tree, flat_set, flat_map, static_vector, small_vector, stable_vector, intrusive_list, intrusive_slist, intrusive_set, intrusive_multiset, intrusive_map, intrusive_multimap, dynamic_bitset, bloom_filter, counted_ptr, shared_ptr, weak_ptr, unique_ptr, scoped_ptr, auto_ptr, raw_ptr, observer_ptr, function, reference_wrapper, allocator, polymorphic_allocator, memory_resource, vector, string, deque, list, forward_list, set, multiset, map, multimap, unordered_set, unordered_multiset, unordered_map, unordered_multimap, monotonic_buffer_resource, pool_resource, synchronized_pool_resource, unsynchronized_pool_resource, locale, ios_base, istream, ostream, iostream, fstream, ifstream, ofstream, stringstream, istringstream, ostringstream, streambuf, filebuf, stringbuf, sync_with_stdio, tie, ignore, get, make_tuple, apply, visit, holds_alternative, get_if, in_place, in_place_type, in_place_index, make_optional, make_variant, make_any

CPP Data Structures: CPP <array>, CPP <bitset>, CPP <deque>, CPP <forward_list>, CPP <list>, CPP <map>, <queue>CPP Queue header - CPP <queue>, CPP <set>, CPP <stack>, CPP <unordered_map>, CPP <unordered_set>, CPP <vector>. (navbar_cpp_containers - see also navbar_cplusplus, navbar_data_structures, navbar_standard_library)

Data Structures: Array, Linked List, Stack, Queue, Binary Tree, Binary Search Tree, Heap, Hash Table, Graph, Trie, Skip List, Red-Black Tree, AVL Tree, B-Tree, B+ Tree, Splay Tree, Fibonacci Heap, Disjoint Set, Adjacency Matrix, Adjacency List, Circular Linked List, Doubly Linked List, Priority Queue, Dynamic Array, Bloom Filter, Segment Tree, Fenwick Tree, Cartesian Tree, Rope, Suffix Array, Suffix Tree, Ternary Search Tree, Radix Tree, Quadtree, Octree, KD Tree, Interval Tree, Sparse Table, Union-Find, Min-Max Heap, Binomial Heap, And-Or Graph, Bit Array, Bitmask, Circular Buffer, Concurrent Data Structures, Content Addressable Memory, Deque, Directed Acyclic Graph (DAG), Edge List, Eulerian Path and Circuit, Expression Tree, Huffman Tree, Immutable Data Structure, Indexable Skip List, Inverted Index, Judy Array, K-ary Tree, Lattice, Linked Hash Map, Linked Hash Set, List, Matrix, Merkle Tree, Multimap, Multiset, Nested Data Structure, Object Pool, Pairing Heap, Persistent Data Structure, Quad-edge, Queue (Double-ended), R-Tree, Radix Sort Tree, Range Tree, Record, Ring Buffer, Scene Graph, Scapegoat Tree, Soft Heap, Sparse Matrix, Spatial Index, Stack (Min/Max), Suffix Automaton, Threaded Binary Tree, Treap, Triple Store, Turing Machine, Unrolled Linked List, Van Emde Boas Tree, Vector, VList, Weak Heap, Weight-balanced Tree, X-fast Trie, Y-fast Trie, Z-order, Zero-suppressed Decision Diagram, Zigzag Tree

Data Structures Fundamentals - Algorithms Fundamentals, Algorithms, Data Types; Primitive Types (Boolean data type, Character (computing), Floating-point arithmetic, Single-precision floating-point format - Double-precision floating-point format, IEEE 754, Category:Floating point types, Fixed-point arithmetic, Integer (computer science), Reference (computer science), Pointer (computer programming), Enumerated type, Date Time);

Composite Types or Non-Primitive Types: Array data structure, String (computer science) (Array of characters), Record (computer science) (also called Struct (C programming language)), Union type (Tagged union, also called Variant type, Variant record, Discriminated union, or Disjoint union);

Abstract Data Types: Container (data structure), List (abstract data type), Tuple, Associative array (also called Map, Multimap, Set (abstract data type), Multiset (abstract data type) (also called Multiset (bag)), Stack (abstract data type), Queue (abstract data type), (e.g. Priority queue), Double-ended queue, Graph (data structure) (e.g. Tree (data structure), Heap (data structure))

Data Structures and Algorithms, Data Structures Syntax, Data Structures and OOP - Data Structures and Design Patterns, Data Structures Best Practices, Data Structures and Containerization, Data Structures and IDEs (IntelliSense), Data Structures and Development Tools, Data Structures and Compilers, Data Structures and Data Science - Data Structures and DataOps, Machine Learning Data Structures - Data Structures and MLOps, Deep Learning Data Structures, Functional Data Structures, Data Structures and Concurrency - Data Structures and Parallel Programming, Data Structure Libraries, Data Structures History, Data Structures Bibliography (Grokking Data Structures), Data Structures Courses, Data Structures Glossary, Data Structures Topics, Data Structures Research, Data Structures GitHub, Written in Data Structures, Data Structures Popularity, Data Structures Awesome. (navbar_data_structures - see also navbar_cpp_containers, navbar_math_algorithms, navbar_data_algorithms, navbar_design_patterns, navbar_software_architecture)

C++: C++ Fundamentals, C++ Inventor - C++ Language Designer: Bjarne Stroustrup in 1985; C++ Keywords, C++ Built-In Data Types, C++ Data Structures (CPP Containers) - C++ Algorithms, C++ Syntax, C++ OOP - C++ Design Patterns, Clean C++ - C++ Style Guide, C++ Best Practices ( C++ Core Guidelines (CG)) - C++ BDD, C++ Standards ( C++ 23, C++ 20, C++ 17, C++ 14, C++ 11, C++ 03, C++ 98), Bjarne Stroustrup's C++ Glossary, CppReference.com, CPlusPlus.com, ISOcpp.org, C++ Compilers (Compiler Explorer, MinGW), C++ IDEs, C++ Development Tools, C++ Linter, C++ Debugging, C++ Modules ( C++20), C++ Packages, C++ Package Manager ( Conan - the C/C++ Package Manager), C++ Standard Library, C++ Libraries, C++ Frameworks, C++ DevOps - C++ SRE, C++ CI/CD ( C++ Build Pipeline), C++ Data Science - C++ DataOps, C++ Machine Learning, C++ Deep Learning, Functional C++, C++ Concurrency, C++ History, C++ Topics, C++ Bibliography, Manning C++ Series, C++ Courses, CppCon, C++ Research, C++ GitHub, Written in C++, C++ Popularity, C++ Awesome , C++ Versions. (navbar_cplusplus – see also navbar_cpp_containers, navbar_cppcon, navbar_cpp_core_guidelines, navbar_cpp23, navbar_cpp20, navbar_cpp17, navbar_cpp14, navbar_cpp11)


© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.