MyGUI
3.0.1
Main Page
Related Pages
Namespaces
Data Structures
Files
Examples
File List
Globals
MyGUIEngine
include
MyGUI_Bitwise.h
Go to the documentation of this file.
1
7
/*
8
This file is part of MyGUI.
9
10
MyGUI is free software: you can redistribute it and/or modify
11
it under the terms of the GNU Lesser General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
14
15
MyGUI is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU Lesser General Public License for more details.
19
20
You should have received a copy of the GNU Lesser General Public License
21
along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22
*/
23
#ifndef __MYGUI_BITWISE_H__
24
#define __MYGUI_BITWISE_H__
25
26
#include "
MyGUI_Prerequest.h
"
27
28
namespace
MyGUI
29
{
30
31
class
Bitwise
32
{
33
public
:
36
template
<
typename
Type>
37
static
MYGUI_FORCEINLINE
Type
firstPO2From
(Type _value)
38
{
39
--_value;
40
_value |= _value >> 16;
41
_value |= _value >> 8;
42
_value |= _value >> 4;
43
_value |= _value >> 2;
44
_value |= _value >> 1;
45
++_value;
46
return
_value;
47
}
48
50
template
<
typename
Type>
51
static
MYGUI_FORCEINLINE
bool
isPO2
(Type _value)
52
{
53
return
(_value & (_value-1)) == 0;
54
}
55
59
template
<
typename
Type>
60
static
MYGUI_FORCEINLINE
size_t
getBitShift
(Type _mask)
61
{
62
if
(_mask == 0)
63
return
0;
64
65
size_t
result = 0;
66
while
((_mask & 1) == 0)
67
{
68
++result;
69
_mask >>= 1;
70
}
71
return
result;
72
}
73
74
};
75
76
}
// namespace MyGUI
77
78
#endif // __MYGUI_BITWISE_H__
Generated by
1.8.1.2