Rev 1596 | Rev 1598 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1596 | Rev 1597 | ||
|---|---|---|---|
| Line 67... | Line 67... | ||
| 67 | if (position >= this->count_) |
67 | if (position >= this->count_) |
| 68 | { |
68 | { |
| 69 | return -1; |
69 | return -1; |
| 70 | } |
70 | } |
| 71 | 71 | ||
| - | 72 | unsigned int byte_position = position / 8; |
|
| - | 73 | unsigned int bit_position = 7 - (position - (byte_position * 8)); |
|
| - | 74 | ||
| 72 | this->bytes_[ |
75 | this->bytes_[byte_position] |= (0x00000001 << (bit_position)); |
| 73 | 76 | ||
| 74 | return 0; |
77 | return 0; |
| 75 | } |
78 | } |
| 76 | 79 | ||
| 77 | int Bitset::Unset(unsigned int position) |
80 | int Bitset::Unset(unsigned int position) |
| 78 | { |
81 | { |
| 79 | if (position >= this->count_) |
82 | if (position >= this->count_) |
| 80 | { |
83 | { |
| 81 | return -1; |
84 | return -1; |
| 82 | } |
85 | } |
| - | 86 | ||
| - | 87 | unsigned int byte_position = position / 8; |
|
| - | 88 | unsigned int bit_position = 7 - (position - (byte_position * 8)); |
|
| 83 | 89 | ||
| 84 | this->bytes_[ |
90 | this->bytes_[byte_position] &= ~(0x00000001 << (bit_position)); |
| 85 | 91 | ||
| 86 | return 0; |
92 | return 0; |
| 87 | } |
93 | } |
| 88 | 94 | ||
| 89 | int Bitset::Get(unsigned int position) |
95 | int Bitset::Get(unsigned int position) |
| 90 | { |
96 | { |
| 91 | if (position >= this->count_) |
97 | if (position >= this->count_) |
| 92 | { |
98 | { |
| 93 | return -1; |
99 | return -1; |
| 94 | } |
100 | } |
| 95 | 101 | ||
| - | 102 | unsigned int byte_position = position / 8; |
|
| - | 103 | unsigned int bit_position = 7 - (position - (byte_position * 8)); |
|
| - | 104 | ||
| 96 | return (this->bytes_[ |
105 | return (this->bytes_[byte_position] & (0x00000001 << bit_position) ? 1 : 0); |
| 97 | } |
106 | } |
| 98 | 107 | ||
| 99 | }; // namespace type |
108 | }; // namespace type |
| 100 | }; // namespace atom |
109 | }; // namespace atom |