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

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

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

RubyHash.size介绍

暂无

代码示例

代码示例来源:origin: asciidoctor/asciidoctorj

@Override
public int size() {
  return rubyHash.size();
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

@Override
public int size() {
  return rubyHash.size();
}

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

@SuppressWarnings("unchecked")
public String[] getEnv() {
  RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV");
  String[] env = new String[hash.size()];
  if (env.length == 0) return env;
  StringBuilder str = new StringBuilder(); int i=0;
  for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) {
    Map.Entry<Object, Object> entry = iter.next();
    str.setLength(0);
    str.append(entry.getKey()).append('=').append(entry.getValue());
    env[i] = str.toString();
  }
  return env;
}

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

@SuppressWarnings("unchecked")
public String[] getEnv() {
  RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV");
  int i=0;
  String[] env = new String[hash.size()];
  for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) {
    Map.Entry<Object, Object> entry = iter.next();
    env[i] = entry.getKey().toString() + "=" + entry.getValue().toString();
  }
  return env;
}

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

@SuppressWarnings("unchecked")
public String[] getEnv() {
  RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV");
  int i=0;
  String[] env = new String[hash.size()];
  for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) {
    Map.Entry<Object, Object> entry = iter.next();
    env[i] = entry.getKey().toString() + "=" + entry.getValue().toString();
  }
  return env;
}

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

@SuppressWarnings("unchecked")
public String[] getEnv() {
  RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV");
  String[] env = new String[hash.size()];
  if (env.length == 0) return env;
  StringBuilder str = new StringBuilder(); int i=0;
  for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) {
    Map.Entry<Object, Object> entry = iter.next();
    str.setLength(0);
    str.append(entry.getKey()).append('=').append(entry.getValue());
    env[i] = str.toString();
  }
  return env;
}

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

@JRubyMethod(name = "<", required = 1)
public IRubyObject op_lt(ThreadContext context, IRubyObject other) {
  final RubyHash otherHash = ((RubyBasicObject) other).convertToHash();
  if (size() >= otherHash.size()) return context.fals;
  return RubyBoolean.newBoolean(context.runtime, hash_le(otherHash));
}

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

@JRubyMethod(name = "<=", required = 1)
public IRubyObject op_le(ThreadContext context, IRubyObject other) {
  final RubyHash otherHash = other.convertToHash();
  if (size() > otherHash.size()) return context.fals;
  return RubyBoolean.newBoolean(context.runtime, hash_le(otherHash));
}

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

@JRubyMethod(name = "<", required = 1)
public IRubyObject op_lt(ThreadContext context, IRubyObject other) {
  final RubyHash otherHash = ((RubyBasicObject) other).convertToHash();
  if (size() >= otherHash.size()) return context.fals;
  return RubyBoolean.newBoolean(context.runtime, hash_le(otherHash));
}

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

@JRubyMethod(name = "<=", required = 1)
public IRubyObject op_le(ThreadContext context, IRubyObject other) {
  final RubyHash otherHash = other.convertToHash();
  if (size() > otherHash.size()) return context.fals;
  return RubyBoolean.newBoolean(context.runtime, hash_le(otherHash));
}

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

@JRubyMethod(name = "hash")
public RubyFixnum hash(ThreadContext context) {
  final int size = size();
  long[] hval = { Helpers.hashStart(context.runtime, size) };
  if (size > 0) {
    iteratorVisitAll(context, CalculateHashVisitor, hval);
  }
  return context.runtime.newFixnum(hval[0]);
}

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

@JRubyMethod(name = "hash")
public RubyFixnum hash(ThreadContext context) {
  final int size = size();
  long[] hval = { Helpers.hashStart(context.runtime, size) };
  if (size > 0) {
    iteratorVisitAll(context, CalculateHashVisitor, hval);
  }
  return context.runtime.newFixnum(hval[0]);
}

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

@JRubyMethod(name = "uniq")
public IRubyObject uniq19(ThreadContext context, Block block) {
  if (!block.isGiven()) return uniq(context);
  RubyHash hash = makeHash(context, block);
  RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
  hash.visitAll(context, RubyHash.StoreValueVisitor, result);
  return result;
}

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

private static String mapCharset(ThreadContext context, IRubyObject val) {
  RubyHash charset = val.getRuntime().getCharsetMap();
  if (charset.size() > 0) {
    RubyString key = val.callMethod(context, "downcase").convertToString();
    IRubyObject tryVal = charset.fastARef(key);
    if (tryVal != null) val = tryVal;
  }
  return val.convertToString().toString();
}

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

@JRubyMethod(name = "uniq")
public IRubyObject uniq19(ThreadContext context, Block block) {
  if (!block.isGiven()) return uniq(context);
  RubyHash hash = makeHash(context, block);
  RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
  hash.visitAll(context, RubyHash.StoreValueVisitor, result);
  return result;
}

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

private static String mapCharset(ThreadContext context, IRubyObject val) {
  RubyHash charset = val.getRuntime().getCharsetMap();
  if (charset.size() > 0) {
    RubyString key = val.callMethod(context, "downcase").convertToString();
    IRubyObject tryVal = charset.fastARef(key);
    if (tryVal != null) val = tryVal;
  }
  return val.convertToString().toString();
}

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

@JRubyMethod(name = "uniq", compat = RUBY1_9)
public IRubyObject uniq19(ThreadContext context, Block block) {
  if (!block.isGiven()) return uniq(context);
  RubyHash hash = makeHash(context, block);
  final RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
  hash.visitAll(new RubyHash.Visitor() {
    @Override
    public void visit(IRubyObject key, IRubyObject value) {
      result.append(value);
    }
  });
  return result;
}

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

@JRubyMethod(name = "uniq", compat = RUBY1_9)
public IRubyObject uniq19(ThreadContext context, Block block) {
  if (!block.isGiven()) return uniq(context);
  RubyHash hash = makeHash(context, block);
  final RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
  hash.visitAll(new RubyHash.Visitor() {
    @Override
    public void visit(IRubyObject key, IRubyObject value) {
      result.append(value);
    }
  });
  return result;
}

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

@JRubyMethod(name = "uniq!")
public IRubyObject uniq_bang19(ThreadContext context, Block block) {
  modifyCheck();
  if (!block.isGiven()) return uniq_bang(context);
  RubyHash hash = makeHash(context, block);
  if (realLength == hash.size()) return context.nil;
  // after evaluating the block, a new modify check is needed
  modifyCheck();
  // TODO: (CON) This could be a no-op for packed arrays if size does not change
  unpack();
  realLength = 0;
  hash.visitAll(context, RubyHash.StoreValueVisitor, this);
  return this;
}

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

@JRubyMethod(name = "uniq!")
public IRubyObject uniq_bang19(ThreadContext context, Block block) {
  modifyCheck();
  if (!block.isGiven()) return uniq_bang(context);
  RubyHash hash = makeHash(context, block);
  if (realLength == hash.size()) return context.nil;
  // after evaluating the block, a new modify check is needed
  modifyCheck();
  // TODO: (CON) This could be a no-op for packed arrays if size does not change
  unpack();
  realLength = 0;
  hash.visitAll(context, RubyHash.StoreValueVisitor, this);
  return this;
}

相关文章

微信公众号

最新文章

更多

RubyHash类方法