This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
functions:swap [2017/03/15 08:46] – created 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; | ||
- | </ |