Sha256: 8d92bba38b7374015fa68567ec6f3162cf609415575ffb7fe0a8068d07567480

Contents?: true

Size: 411 Bytes

Versions: 13

Compression:

Stored size: 411 Bytes

Contents

module Antlr4::Runtime

  class PredictionContextCache
    def initialize
      @cache = {}
    end

    def add(ctx)
      return EmptyPredictionContext::EMPTY if ctx == EmptyPredictionContext::EMPTY

      existing = @cache[ctx]
      return existing unless existing.nil?

      @cache[ctx] = ctx
      ctx
    end

    def get(ctx)
      @cache[ctx]
    end

    def size
      @cache.size
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
antlr4-runtime-0.2.12 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.11 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.10 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.9 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.8 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.7 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.6 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.5 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.4 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.3 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.2 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.1 lib/antlr4/runtime/prediction_context_cache.rb
antlr4-runtime-0.2.0 lib/antlr4/runtime/prediction_context_cache.rb