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

Function swap

Exercises/NoModules/Chapter 08/Soln8_06.cpp:86–91  ·  view source on GitHub ↗

Swap numbers at position first with address at position second

Source from the content-addressed store, hash-verified

84
85// Swap numbers at position first with address at position second
86void swap(std::vector<unsigned>& numbers, size_t first, size_t second)
87{
88 auto temp{ numbers[first] };
89 numbers[first] = numbers[second];
90 numbers[second] = temp;
91}
92
93// Recursive helper function to sort numbers in ascending sequence
94// 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