Abstract binning algorithm. Following invariant is expected to hold:
toIndex . fromIndex == id
Reverse is not nessearily true.