| 217 | } |
| 218 | |
| 219 | void TSIntegerSet::insert(S32 index, bool value) |
| 220 | { |
| 221 | AssertFatal(index<MAX_TS_SET_SIZE,"TSIntegerSet::insert: out of range"); |
| 222 | |
| 223 | // shift bits in words after the insertion point |
| 224 | U32 endWord = (end() >> 5) + 1; |
| 225 | if (endWord >= MAX_TS_SET_DWORDS) |
| 226 | endWord = MAX_TS_SET_DWORDS-1; |
| 227 | |
| 228 | for (S32 i = endWord; i > (index >> 5); i--) |
| 229 | { |
| 230 | bits[i] = bits[i] << 1; |
| 231 | if (bits[i-1] & 0x80000000) |
| 232 | bits[i] |= 0x1; |
| 233 | } |
| 234 | |
| 235 | // shift to create space in target word |
| 236 | U32 lowMask = (1 << (index & 0x1f)) - 1; // bits below the insert point |
| 237 | U32 highMask = ~(lowMask | (1 << (index & 0x1f))); // bits above the insert point |
| 238 | |
| 239 | S32 word = index >> 5; |
| 240 | bits[word] = ((bits[word] << 1) & highMask) | (bits[word] & lowMask); |
| 241 | |
| 242 | // insert new value |
| 243 | if (value) |
| 244 | set(index); |
| 245 | } |
| 246 | |
| 247 | void TSIntegerSet::erase(S32 index) |
| 248 | { |
no test coverage detected