Class: Antlr4::Runtime::DoubleKeyMap

Inherits:
Object
  • Object
show all
Defined in:
lib/antlr4/runtime/double_key_map.rb

Instance Method Summary collapse

Constructor Details

#initializeDoubleKeyMap

Returns a new instance of DoubleKeyMap



3
4
5
# File 'lib/antlr4/runtime/double_key_map.rb', line 3

def initialize
  @data = {}
end

Instance Method Details

#get1(k1) ⇒ Object



27
28
29
# File 'lib/antlr4/runtime/double_key_map.rb', line 27

def get1(k1)
  @data[k1]
end

#get2(k1, k2) ⇒ Object



20
21
22
23
24
25
# File 'lib/antlr4/runtime/double_key_map.rb', line 20

def get2(k1, k2)
  data2 = @data[k1]
  return nil if data2.nil?

  data2[k2]
end

#key_set0Object



38
39
40
# File 'lib/antlr4/runtime/double_key_map.rb', line 38

def key_set0
  @data.keys
end

#key_set1(k1) ⇒ Object



42
43
44
45
46
47
# File 'lib/antlr4/runtime/double_key_map.rb', line 42

def key_set1(k1)
  data2 = @data[k1]
  return nil if data2.nil?

  data2.keys
end

#put(k1, k2, v) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/antlr4/runtime/double_key_map.rb', line 7

def put(k1, k2, v)
  data2 = @data[k1]
  prev = nil
  if data2.nil?
    data2 = {}
    @data[k1] = data2
  else
    prev = data2[k2]
  end
  data2[k2] = v
  prev
end

#values(k1) ⇒ Object



31
32
33
34
35
36
# File 'lib/antlr4/runtime/double_key_map.rb', line 31

def values(k1)
  data2 = @data[k1]
  return nil if data2.nil?

  data2.values
end