Skip to content

Instantly share code, notes, and snippets.

@alvesjnr
Created July 11, 2011 20:54
Show Gist options
  • Select an option

  • Save alvesjnr/1076774 to your computer and use it in GitHub Desktop.

Select an option

Save alvesjnr/1076774 to your computer and use it in GitHub Desktop.
Interval structure
Implement an efficient data structure for storing keys in intervals
mapping to values. The interval is defined as a 2-tuple: {low, high}.
When creating a new map the user can choose if the interval is open or
closed, in both ends.
Eg. given the left-closed, right-open map M=
[1, 10) -> a
[10, 20) -> b
[20, 30) -> c
find(1,M) = a
find(15,M) = b
find(20,M) = c
find(30,M) – EXCEPTION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment