Method: Roaring::BitmapCommon#initialize

Defined in:
lib/roaring.rb

#initialize(enum = nil) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/roaring.rb', line 89

def initialize(enum = nil)
  return unless enum

  if enum.instance_of?(self.class)
    replace(enum)
  elsif Range === enum
    if enum.exclude_end?
      add_range(enum.begin, enum.end)
    else
      add_range_closed(enum.begin, enum.end)
    end
  else
    enum.each { |x| self << x }
  end
end