Method: Immutable::SortedSet#below

Defined in:
lib/immutable/sorted_set.rb

#below(item) ⇒ SortedSet #below(item) {|item| ... } ⇒ nil

Select elements less than a value.

Overloads:

  • #below(item) ⇒ SortedSet

    Return a new SortedSet containing all items less than item.

    Examples:

    s = Immutable::SortedSet[2, 4, 6, 8, 10]
    s.below(6)
    # => Immutable::SortedSet[2, 4]
    

    Returns:

  • #below(item) {|item| ... } ⇒ nil

    Examples:

    s = Immutable::SortedSet[2, 4, 6, 8, 10]
    s.below(6) { |e| puts "Element: #{e}" }
    
    Element: 2
    Element: 4 
    # => nil
    

    Yields:

    • (item)

      Once for each item less than item, in order from lowest to highest.

    Returns:

    • (nil)

Parameters:

  • item (Object)


788
789
790
791
792
793
794
# File 'lib/immutable/sorted_set.rb', line 788

def below(item, &block)
  if block_given?
    @node.each_less(item, false, &block)
  else
    self.class.alloc(@node.prefix(item, false))
  end
end