This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| functions:swap [2017/03/15 08:52] – korshun | functions:swap [2019/09/05 20:41] (current) – removed korshun | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== swap ====== | ||
| - | {{tag> | ||
| - | '' | ||
| - | [[: | ||
| - | |||
| - | [[: | ||
| - | |||
| - | ===== Description ===== | ||
| - | Returns two variables in a swapped order. This function exists to improve readability. | ||
| - | |||
| - | ===== Examples ===== | ||
| - | Without swap(): | ||
| - | < | ||
| - | int tmp = x; | ||
| - | x = y; | ||
| - | y = tmp; | ||
| - | </ | ||
| - | |||
| - | With swap(): | ||
| - | < | ||
| - | swap(x, y); | ||
| - | x = r1; | ||
| - | y = r2; | ||
| - | </ | ||