Class: Ori::LazyHashSet

Inherits:
LazyEnumerable show all
Defined in:
lib/ori/lazy.rb

Constant Summary collapse

INIT =
proc { Hash.new { |hash, key| hash[key] = Set.new } }

Instance Method Summary collapse

Methods inherited from LazyEnumerable

#any?, #delete_if, #each, #empty?

Methods inherited from Lazy

#initialized?, #internal

Constructor Details

#initializeLazyHashSet

Returns a new instance of LazyHashSet.



136
137
138
# File 'lib/ori/lazy.rb', line 136

def initialize
  super(INIT)
end

Instance Method Details

#[](key) ⇒ Object



140
141
142
# File 'lib/ori/lazy.rb', line 140

def [](key)
  internal[key]
end

#[]=(key, value) ⇒ Object



144
145
146
# File 'lib/ori/lazy.rb', line 144

def []=(key, value)
  internal[key] = value
end

#delete(key) ⇒ Object



160
161
162
# File 'lib/ori/lazy.rb', line 160

def delete(key)
  internal.delete(key) if initialized?
end

#keysObject



154
155
156
157
158
# File 'lib/ori/lazy.rb', line 154

def keys
  return [] unless initialized?

  internal.keys
end

#none?(&block) ⇒ Boolean

Returns:

  • (Boolean)


148
149
150
151
152
# File 'lib/ori/lazy.rb', line 148

def none?(&block)
  return true unless initialized?

  internal.none?(&block)
end