class Hamster::SortedSet
def fetch(index, default = (missing_default = true))
-
(Object)
-
Parameters:
-
default
(Object
) -- Object to return if the key is not found -
index
(Integer
) -- The index to look up -
index
(Integer
) -- The index to look up -
index
(Integer
) -- The index to look up
Overloads:
-
fetch(index, default)
-
fetch(index) { |index| ... }
-
fetch(index)
Other tags:
- Yieldreturn: - Default value to return
Other tags:
- Yieldparam: index - The index which does not exist
Other tags:
- Yield: - Once if the index is not found.
Raises:
-
(IndexError)
- if index does not exist
def fetch(index, default = (missing_default = true)) if index >= -@node.size && index < @node.size at(index) elsif block_given? yield(index) elsif !missing_default default else raise IndexError, "index #{index} outside of sorted set bounds" end end