Skip to content

Instantly share code, notes, and snippets.

@tim-evans
Created January 6, 2012 15:26
Show Gist options
  • Select an option

  • Save tim-evans/1571050 to your computer and use it in GitHub Desktop.

Select an option

Save tim-evans/1571050 to your computer and use it in GitHub Desktop.
IndexSet hinting bug
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