Sha256: 85268945590d4d6c61b013bbcd953aca29685a5f844f23c9b9fc04b51c1e0b4d

Contents?: true

Size: 874 Bytes

Versions: 2

Compression:

Stored size: 874 Bytes

Contents

module Antlr4::Runtime
  class Triple
    attr_accessor :a
    attr_accessor :b
    attr_accessor :c

    def initialize(a, b, c)
      @a = a
      @b = b
      @c = c
    end

    def eql?(obj)
      if obj == self
        return true
      else
        return false unless obj.is_a? Triple
      end

      ObjectEqualityComparator.instance.compare(a, obj.a).zero? && ObjectEqualityComparator.instance.compare(b, obj.b).zero? && ObjectEqualityComparator.instance.compare(c, obj.c).zero?
    end

    def hash
      hash_code = MurmurHash.hash_objs([@a, @b, @c])

      if !@_hash.nil?
        if hash_code == @_hash
          puts 'Same hash_code for Triple'
        else
          puts 'Different hash_code for Triple'
        end
      end
      @_hash = hash_code
    end

    def to_s
      '(' << @a.to_s << ',' << @b.to_s << ', ' << @c.to_s << ')'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
antlr4-runtime-0.2.3 lib/antlr4/runtime/triple.rb
antlr4-runtime-0.2.2 lib/antlr4/runtime/triple.rb