org.jruby.RubyHash.op_equal()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中org.jruby.RubyHash.op_equal方法的一些代码示例,展示了RubyHash.op_equal的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyHash.op_equal方法的具体详情如下:
包路径:org.jruby.RubyHash
类名称:RubyHash
方法名:op_equal

RubyHash.op_equal介绍

[英]rb_hash_equal
[中]rb_hash_equal

代码示例

代码示例来源:origin: bazelbuild/bazel

@JRubyMethod(name = "==")
public IRubyObject eq(ThreadContext context, IRubyObject _other) {
  if (_other instanceof RubyHash)
    return toHash(context).op_equal(context, _other);
  RubyMap other = (RubyMap) _other;
  if (this == other) return context.runtime.getTrue();
  if (!typeCompatible(other) || this.table.size() != other.table.size())
    return context.runtime.getFalse();
  for (IRubyObject key : table.keySet()) {
    if (! other.table.containsKey(key))
      return context.runtime.getFalse();
    if (! other.table.get(key).equals(table.get(key)))
      return context.runtime.getFalse();
  }
  return context.runtime.getTrue();
}

代码示例来源:origin: org.jruby/jruby-core

@Override
public boolean equals(Object other) {
  if (!(other instanceof RubyHash)) return false;
  if (this == other) return true;
  return op_equal(getRuntime().getCurrentContext(), (RubyHash)other).isTrue();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@Override
public boolean equals(Object other) {
  if (!(other instanceof RubyHash)) return false;
  if (this == other) return true;
  return op_equal(getRuntime().getCurrentContext(), (RubyHash)other).isTrue() ? true : false;
}

代码示例来源:origin: org.jruby/jruby-complete

@Override
public boolean equals(Object other) {
  if (!(other instanceof RubyHash)) return false;
  if (this == other) return true;
  return op_equal(getRuntime().getCurrentContext(), (RubyHash)other).isTrue();
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@Override
public boolean equals(Object other) {
  if (!(other instanceof RubyHash)) return false;
  if (this == other) return true;
  return op_equal(getRuntime().getCurrentContext(), (RubyHash)other).isTrue() ? true : false;
}

代码示例来源:origin: org.jruby/jruby-complete

@Override
@JRubyMethod(name = "==")
public IRubyObject op_equal(ThreadContext context, IRubyObject other) {
  if ( this == other ) return context.tru;
  if ( getMetaClass().isInstance(other) ) {
    return this.hash.op_equal(context, ((RubySet) other).hash); // @hash == ...
  }
  if ( other instanceof RubySet ) {
    RubySet that = (RubySet) other;
    if ( this.size() == that.size() ) { // && includes all of our elements :
      for ( IRubyObject obj : elementsOrdered() ) {
        if ( ! that.containsImpl(obj) ) return context.fals;
      }
      return context.tru;
    }
  }
  return context.fals;
}

代码示例来源:origin: org.jruby/jruby-core

@Override
@JRubyMethod(name = "==")
public IRubyObject op_equal(ThreadContext context, IRubyObject other) {
  if ( this == other ) return context.tru;
  if ( getMetaClass().isInstance(other) ) {
    return this.hash.op_equal(context, ((RubySet) other).hash); // @hash == ...
  }
  if ( other instanceof RubySet ) {
    RubySet that = (RubySet) other;
    if ( this.size() == that.size() ) { // && includes all of our elements :
      for ( IRubyObject obj : elementsOrdered() ) {
        if ( ! that.containsImpl(obj) ) return context.fals;
      }
      return context.tru;
    }
  }
  return context.fals;
}

相关文章

微信公众号

最新文章

更多

RubyHash类方法