Back to Basics: Classic 9STLIterators provide a common unit of information exchange between containers and algorithms 17 Container {e0, e1, e2, …} Iterator AlgorithmCppCon 2021 – Back to Basics: Classic STL Copyright © 2021 Bob Iterators provide a common unit of information exchange between containers and algorithms 18 Container {e0, e1, e2, …} Iterator AlgorithmCppCon 2021 – Back to Basics: Classic STL Copyright © 2021 Bob elements via associated iterators • A container's iterators understand (and abstract) that container's internal structure • Iterators • Provide access to container elements through well-defined interfaces0 码力 | 75 页 | 603.36 KB | 6 月前3
Object Introspection: A Revolutionary Memory Profiler for C++ ObjectsDebugInfo Container std::string Container std::vectorPrimitive int Member: n Member: bar_vec Member: foo_str Template Param Member: str Struct Foo Struct BarType Graph Container std::string std::string Container std::vector Primitive int Member: n Member: bar_vec Member: foo_str Template Param Member: str Struct Foo Struct BarContainer std::string Container std::vector std::vector bar_vec; std::string foo_str; }; ReconstructedContainer std::string Container std::vector Primitive int Member: n Member: bar_vec Member: foo_str Template Param 0 码力 | 62 页 | 2.24 MB | 6 月前3
Interesting Upcoming Features from Low Latency, Parallelism and Concurrency(Asynchronous Reclamation Only) Hazard Pointer Synchronous Reclamation templateclass Container { class Obj : hazard_pointer_obj_base { T data; /* etc */ }; void insert(T data) { Remove obj from container */ obj->retire(); } }; class A { // Deleter does not depend on resources // with independent lifetime. ~A(); }; { Container container; container.insert(a); container container.erase(a); } // Obj containing 'a' may be not deleted yet. template class Container { class Obj : hazard_pointer_obj_base { T data; /* etc */ }; void insert(T data) { 0 码力 | 56 页 | 514.85 KB | 6 月前3
Modern C++ Tutorial: C++11/14/17/20 On the Fly. . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Chapter 04 Containers 50 4.1 Linear Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 std::array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 4.2 Unordered Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 4.3 Tuples other languages. In the chapter on containers, we will learn that C++11 has added a std::tuple container for constructing a tuple that encloses multiple return values. But the flaw is that C++11/14 does0 码力 | 92 页 | 1.79 MB | 1 年前3
Data Structures That Make Video Games Go Roundsequence length (PSL) keeps growing, inserted elements starts clustering around the mean of the container. Ideally, you would keep the PSL for each element roughly the same. ● An element with a PSL of reference stability.Trivial solutions to remaining problems: ● Introduce a free list into the container. ● Free list can be FIFO or LIFO. ● Don’t shift contents when an element that is not in the free list.Free List Trivial solutions to remaining problems: ● Introduce a free list into the container. ● Free list can be FIFO or LIFO. ● Don’t shift contents when an element that is not in the0 码力 | 196 页 | 3.03 MB | 6 月前3
Bridging the Gap: Writing Portable Programs for CPU and GPUDisable Cuda warnings - Problem � � 1 2 template < typename Container > 3 __host__ __device__ constexpr 4 void fill_ones( Container & ct ) { 5 for ( auto & x : ct ) x = 1; 6 } 7 8 #includeContainer > 3 __host__ __device__ constexpr 4 void fill_ones( Container & ct ) { 5 for ( auto & x : ct ) x = 1; 6 } 7 8 #include Container > 3 __host__ __device__ constexpr 4 void fill_ones( Container & ct ) { 5 for ( auto & x : ct ) x = 1; 6 } 7 8 #include 0 码力 | 124 页 | 4.10 MB | 6 月前3
A Multithreaded, Transaction-Based Locking Strategy for ContainersC O M P U T I N GCopyright © 2020 Bob Steagall K E W B C O M P U T I N G Overview • Sharing a container among multiple threads • A motivating problem • Some possible solutions • A solution based on for Containers 2Copyright © 2020 Bob Steagall K E W B C O M P U T I N G Sharing a Container • Sometimes a container must be shared between threads • We desire to avoid race conditions during writes Locking Strategy for Containers 3Copyright © 2020 Bob Steagall K E W B C O M P U T I N G Sharing a Container – Avoiding Race Conditions • If all threads are readers… • No locking is required • If the number0 码力 | 142 页 | 474.78 KB | 6 月前3
Using Modern C++ to Build XOffsetDatastructurerepresentations. struct Item struct Equip : public Item • Containers: Our system can handle container types, such as vector of float values. XVectorattributes; Fanchen Su, XOffsetDatastructure its performance is comparable to, and in some cases even slightly exceed, that of STL and Boost Container libraries. • As you can see in the chart, our solution demonstrates a slight performance advantage Library. Allocators handle all the requests for allocation and deallocation of memory for a given container.' Fanchen Su, XOffsetDatastructure, CppCon 2024 745.1 Custom Allocator • Allocator • According 0 码力 | 111 页 | 3.03 MB | 6 月前3
Pipes: How Plumbing Can Make Your C++ Code More Expressiveassertion failed: Cannot get a view of a temporary container static_assert(std::is_lvalue_reference::value, "Cannot get a view of a temporary container"); std::vector results = getInput() | inputs The pipes Inside a pipe Branching out pipes The output of a pipeline Simple container adapters Complex container adapters for_each20 pipes::transform THE PIPES pipes::filter pipes::join pipes::drop inputs The pipes Inside a pipe Branching out pipes The output of a pipeline Simple container adapters Complex container adapters for_each31 INPUT: RANGES auto const inputs = std::vector {1, 2, 3 0 码力 | 61 页 | 9.52 MB | 6 月前3
Evolution of a Median Algorithmstd::ranges::sort(v); const auto medianIndex = std::size(v) / 2; return v[medianIndex]; } 10Handle Empty Container auto median(std::vector& v) { if (std::empty(v)) throw std::domain_error("requires non-empty std::midpoint (*midNeighbor, *mid); } 25Templatized Version template Container> auto median(Container& c) { using namespace std::ranges; if (std::empty(c)) throw std::domain_error("requires std::midpoint (*midNeighbor, *mid); } 26Return Iterator template Container> auto median(Container& c) { using namespace std::ranges; if (std::empty(c)) throw std::domain_error("requires 0 码力 | 46 页 | 1.06 MB | 6 月前3
共 160 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16
相关搜索词
BacktoBasicsClassic9STLObjectIntrospectionRevolutionaryMemoryProfilerforC++ObjectsInterestingUpcomingFeaturesfromLowLatencyParallelismandConcurrencyModernTutorial11141720OntheFlyDataStructuresThatMakeVideoGamesGoRoundBridgingGapWritingPortableProgramsCPUGPUMultithreadedTransactionBasedLockingStrategyContainersUsingBuildXOffsetDatastructurePipesHowPlumbingCanYourCodeMoreExpressiveEvolutionofMedianAlgorithm













