Class: Antlr4::Runtime::Array2DHashSet::SetIterator

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

Instance Method Summary collapse

Constructor Details

#initialize(data, parent) ⇒ SetIterator

Returns a new instance of SetIterator



388
389
390
391
392
393
# File 'lib/antlr4/runtime/array_2d_hash_set.rb', line 388

def initialize(data, parent)
  @data = data
  @parent = parent
  @next_index = 0
  @removed = true
end

Instance Method Details

#has_nextObject



395
396
397
# File 'lib/antlr4/runtime/array_2d_hash_set.rb', line 395

def has_next
  @next_index < @data.length
end

#nextObject

Raises:

  • (StandardError)


399
400
401
402
403
404
405
406
# File 'lib/antlr4/runtime/array_2d_hash_set.rb', line 399

def next
  raise StandardError unless has_next

  @removed = false
  result = @data[@next_index]
  @next_index += 1
  result
end

#removeObject



408
409
410
411
412
413
# File 'lib/antlr4/runtime/array_2d_hash_set.rb', line 408

def remove
  raise IllegalStateException if @removed

  parent.remove(@data[@next_index - 1])
  @removed = true
end