Class: Pacer::Graph::HashIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/pacer/graph/hash_index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element_type, name) ⇒ HashIndex

Returns a new instance of HashIndex.



5
6
7
8
9
10
11
# File 'lib/pacer/graph/hash_index.rb', line 5

def initialize(element_type, name)
  @type = type
  @name = name
  @data = Hash.new do |h, k|
    h[k] = Hash.new { |h, k| h[k] = Set[] }
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/pacer/graph/hash_index.rb', line 3

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/pacer/graph/hash_index.rb', line 3

def type
  @type
end

Instance Method Details

#count(key, value) ⇒ Object



21
22
23
# File 'lib/pacer/graph/hash_index.rb', line 21

def count(key, value)
  data[key][value].count
end

#get(key, value) ⇒ Object



13
14
15
# File 'lib/pacer/graph/hash_index.rb', line 13

def get(key, value)
  Pacer::Pipes::EnumerablePipe.new data[key][value]
end

#put(key, value, element) ⇒ Object



17
18
19
# File 'lib/pacer/graph/hash_index.rb', line 17

def put(key, value, element)
  data[key][value] << element
end