Created
January 6, 2012 15:26
-
-
Save tim-evans/1571050 to your computer and use it in GitHub Desktop.
IndexSet hinting bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var hintSize = SC.IndexSet.HINT_SIZE, | |
| start, set; | |
| set = SC.IndexSet.create(); | |
| set.add(1); | |
| set.add(hintSize + 1); | |
| // Before adding 2, | |
| // the internal data structure looks like: | |
| // { | |
| // 0 : - 1, // Hole until 1 | |
| // 1 : 2, // End of range is 2 | |
| // 2 : -257, // Hole until 257 | |
| // 256: 2, // Hint points at index 2, which is ok. | |
| // 257: 258, // End of range is 258 | |
| // 258: 0 // End of index set | |
| // } | |
| equals(set.rangeStartForIndex(hintSize), | |
| set.rangeStartForIndex(hintSize - 1)); | |
| set.add(2); | |
| // Assuming SC.IndexSet.HINT_SIZE is 256, | |
| // the internal data structure looks like: | |
| // { | |
| // 0 : - 1, // Hole until 1 | |
| // 1 : 3, // End of range is 3 | |
| // 3 : -257, // Hole until 257 | |
| // 256: 2, // Hint points at index 2, which is invalid. | |
| // 257: 258, // End of range is 258 | |
| // 258: 0 // End of index set | |
| // } | |
| equals(set.rangeStartForIndex(hintSize), | |
| set.rangeStartForIndex(hintSize - 1)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment