| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_ |
| 6 #define UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Finds the last marked bit in the set and clears it. Returns the bit index. | 82 // Finds the last marked bit in the set and clears it. Returns the bit index. |
| 83 // Result is undefined if all bits are unmarked. | 83 // Result is undefined if all bits are unmarked. |
| 84 inline uint32_t clear_last_marked_bit() { | 84 inline uint32_t clear_last_marked_bit() { |
| 85 uint32_t n = last_marked_bit(); | 85 uint32_t n = last_marked_bit(); |
| 86 clear_bit(n); | 86 clear_bit(n); |
| 87 return n; | 87 return n; |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Gets the inde of the specified bit in the set, which is the number of | 90 // Gets the index of the specified bit in the set, which is the number of |
| 91 // marked bits that appear before the specified bit. | 91 // marked bits that appear before the specified bit. |
| 92 inline uint32_t get_index_of_bit(uint32_t n) const { | 92 inline uint32_t get_index_of_bit(uint32_t n) const { |
| 93 DCHECK_LE(n, 31U); | 93 DCHECK_LE(n, 31U); |
| 94 return popcnt(value & ~(0xffffffffUL >> n)); | 94 return popcnt(value & ~(0xffffffffUL >> n)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 inline bool operator==(const BitSet32& other) const { | 97 inline bool operator==(const BitSet32& other) const { |
| 98 return value == other.value; | 98 return value == other.value; |
| 99 } | 99 } |
| 100 inline bool operator!=(const BitSet32& other) const { | 100 inline bool operator!=(const BitSet32& other) const { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 124 } | 124 } |
| 125 static inline uint32_t ctz(uint32_t v) { | 125 static inline uint32_t ctz(uint32_t v) { |
| 126 return popcnt((v & static_cast<uint32_t>(-static_cast<int>(v))) - 1); | 126 return popcnt((v & static_cast<uint32_t>(-static_cast<int>(v))) - 1); |
| 127 } | 127 } |
| 128 #endif | 128 #endif |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 } // namespace ui | 131 } // namespace ui |
| 132 | 132 |
| 133 #endif // UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_ | 133 #endif // UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_ |
| OLD | NEW |