MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / swap

Function swap

Exercises/Modules/Chapter 08/Soln8_06.cpp:87–92  ·  view source on GitHub ↗

Swap numbers at position first with address at position second

Source from the content-addressed store, hash-verified

85
86// Swap numbers at position first with address at position second
87void swap(std::vector<unsigned>& numbers, size_t first, size_t second)
88{
89 auto temp{ numbers[first] };
90 numbers[first] = numbers[second];
91 numbers[second] = temp;
92}
93
94// Recursive helper function to sort numbers in ascending sequence
95// Numbers to be sorted are from words[start] to words[end]

Callers 1

sortFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected