C++ lists and maps
Work with ordered lists and key-value lookups. Follow a pickup roster, change a booking, or combine stock counts from two deliveries.
Lists · build and edit
- Erase-remove idiomClear empty stock bins from the pick list
- Vector copy constructionFreeze the guest list used to print badges
- std::vector::at assignmentCorrect the second stop on a shuttle route
- std::vector::eraseTake a cancelled item off a packing list
- std::vector::insertInsert two pickup stops before the depot
- vector::push_backAdd the last student to the bus register
Lists · positions and ranges
- Vector iterator range constructorSelect two orders for the packing bench
- Vector reverse iteratorsRead a receipt history newest first
- std::vector::at and sizeRead the second name on the pickup roster
Maps · look up and assign
- Conditional update with map::findChange a room assignment only if it is still current
- map::find with a fallbackShow a balance for an item never received
- std::map::erase by iteratorRelease a locker only for its recorded owner
- std::map::findFind a parcel whose driver is still unassigned
- std::map::insert_or_assignUpdate the count for a shelf label
- std::map::try_emplaceKeep the first reservation for a seat
Maps · combine and transform
- Batch insert_or_assignApply weekend opening hours
- std::map of vectorsGroup two parcels on one delivery route
- std::map structured bindingsPrint shelf totals in aisle order
Other collection guides
- std::lower_boundFind the first eligible price tier
- std::stable_sortRank jobs while preserving arrival order
- std::accumulateTotal a batch using a wide accumulator
- std::accumulateAdd the prices on a shopping list
- std::countCount items at the offer price
- std::findCheck for a price in a sale list
- std::min_elementFind the cheapest item in a basket
- std::vector::reserveMake room for more meter readings