Handbook
Glossary
interval-at* ( key map -- value ? )
Factor handbook
»
The language
»
Collections
»
Interval maps
Next:
interval-at ( key map -- value )
Vocabulary
interval-maps
Inputs
key
an
object
map
an
interval-map
Outputs
value
the value for the key, or f
?
whether the key is present
Word description
Looks up a key in an interval map, returning the corresponding value if the item is in an interval in the map, and a boolean flag. The operation takes O(log n) time.
Definition
USING:
classes
interval-maps.private
kernel
sequences.private
;
IN:
interval-maps
:
interval-at*
( key map -- value ? )
interval-map
check-instance
[
drop
]
[
find-interval
]
2bi
[
nip
]
[
interval-contains?
]
2bi
[
third-unsafe
t
]
[
drop
f
f
]
if
;
inline