wasSharp – Diff between revs 3 and 5
?pathlinks?
Rev 3 | Rev 5 | |||
---|---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////// |
1 | /////////////////////////////////////////////////////////////////////////// |
|
2 | // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 // |
2 | // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 // |
|
3 | // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
3 | // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
|
4 | // rights of fair usage, the disclaimer and warranty conditions. // |
4 | // rights of fair usage, the disclaimer and warranty conditions. // |
|
5 | /////////////////////////////////////////////////////////////////////////// |
5 | /////////////////////////////////////////////////////////////////////////// |
|
6 | |
6 | |
|
7 | namespace wasSharp |
7 | namespace wasSharp |
|
8 | { |
8 | { |
|
9 | public class BitTwiddling |
9 | public class BitTwiddling |
|
10 | { |
10 | { |
|
11 | /////////////////////////////////////////////////////////////////////////// |
11 | /////////////////////////////////////////////////////////////////////////// |
|
12 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
12 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
13 | /////////////////////////////////////////////////////////////////////////// |
13 | /////////////////////////////////////////////////////////////////////////// |
|
14 | /// <summary> |
14 | /// <summary> |
|
15 | /// Swaps two integers passed by reference using XOR. |
15 | /// Swaps two integers passed by reference using XOR. |
|
16 | /// </summary> |
16 | /// </summary> |
|
17 | /// <param name="q">first integer to swap</param> |
17 | /// <param name="q">first integer to swap</param> |
|
18 | /// <param name="p">second integer to swap</param> |
18 | /// <param name="p">second integer to swap</param> |
|
19 | public static void wasXORSwap(ref int q, ref int p) |
19 | public static void XORSwap(ref int q, ref int p) |
|
20 | { |
20 | { |
|
21 | q ^= p; |
21 | q ^= p; |
|
22 | p ^= q; |
22 | p ^= q; |
|
23 | q ^= p; |
23 | q ^= p; |
|
24 | } |
24 | } |
|
25 | } |
25 | } |
|
26 | } |
26 | } |
|
27 | |
27 | |
|
28 |
|
28 |
|
|
29 | |
29 | |
|
30 | |
30 | |
|
31 | |
31 | |