Sha256: 886b7c2367f47dbf2fb49410551420499071c977ac30ad175936bc170ddbe019

Contents?: true

Size: 1.39 KB

Versions: 4

Compression:

Stored size: 1.39 KB

Contents

if RUBY_PLATFORM == "java"
  java_import 'gnu.trove.TIntCollection'
  java_import 'gnu.trove.set.hash.TIntHashSet'
  java_import 'gnu.trove.set.hash.TLongHashSet'
  java_import 'gnu.trove.map.hash.TIntObjectHashMap'
  java_import 'gnu.trove.map.hash.TLongObjectHashMap'

  module TMap
    def each
      it = iterator
      while it.has_next
        it.advance
        yield it.key, it.value
      end
    end
  end

  module TSet
    def each
      it = iterator
      while it.has_next
        yield it.next
      end
    end

    def inspect
      if size > 1000
        "#{self.class.name}{too large to display,l=#{size}}"
      else
        to_string
      end
    end
  end

  class TLongObjectHashMap
    include TMap
    alias :has_key? :containsKey
    alias :[] :get
    alias :[]= :put
    alias :length :size
    alias :delete :remove
  end

  class TIntObjectHashMap
    include TMap
    alias :has_key? :containsKey
    alias :[] :get
    alias :[]= :put
    alias :length :size
    alias :delete :remove
  end

  class TLongHashSet
    include TSet
    alias :include? :contains
    alias :length :size
    alias :delete :remove
  end

  class TIntHashSet
    include TSet
    alias :include? :contains
    alias :length :size
    alias :delete :remove

    java_alias :concat_ints, :addAll, [TIntCollection.java_class]

    def concat(list)
      return if !list
      concat_ints list
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
liquid-ext-3.5.3 lib/liquid/trove.rb
liquid-ext-3.5.2 lib/liquid/trove.rb
liquid-ext-3.5.0 lib/liquid/trove.rb
liquid-ext-3.4.2 lib/liquid/trove.rb