本文整理了Java中org.jruby.RubyHash.fastDelete
方法的一些代码示例,展示了RubyHash.fastDelete
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyHash.fastDelete
方法的具体详情如下:
包路径:org.jruby.RubyHash
类名称:RubyHash
方法名:fastDelete
暂无
代码示例来源:origin: org.jruby/jruby-core
protected boolean deleteImpl(final IRubyObject obj) {
hash.modify();
return hash.fastDelete(obj);
}
代码示例来源:origin: org.jruby/jruby-complete
protected boolean deleteImpl(final IRubyObject obj) {
hash.modify();
return hash.fastDelete(obj);
}
代码示例来源:origin: org.jruby/jruby-core
/** rb_ary_uniq_bang
*
*/
public IRubyObject uniq_bang(ThreadContext context) {
RubyHash hash = makeHash();
if (realLength == hash.size()) return context.nil;
// TODO: (CON) This could be a no-op for packed arrays if size does not change
unpack();
int j = 0;
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) store(j++, v);
}
realLength = j;
return this;
}
代码示例来源:origin: org.jruby/jruby-complete
/** rb_ary_uniq_bang
*
*/
public IRubyObject uniq_bang(ThreadContext context) {
RubyHash hash = makeHash();
if (realLength == hash.size()) return context.nil;
// TODO: (CON) This could be a no-op for packed arrays if size does not change
unpack();
int j = 0;
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) store(j++, v);
}
realLength = j;
return this;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/** rb_ary_uniq_bang
*
*/
@JRubyMethod(name = "uniq!", compat = RUBY1_8)
public IRubyObject uniq_bang(ThreadContext context) {
RubyHash hash = makeHash();
if (realLength == hash.size()) return context.runtime.getNil();
int j = 0;
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) store(j++, v);
}
realLength = j;
return this;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/** rb_ary_uniq_bang
*
*/
@JRubyMethod(name = "uniq!", compat = RUBY1_8)
public IRubyObject uniq_bang(ThreadContext context) {
RubyHash hash = makeHash();
if (realLength == hash.size()) return context.runtime.getNil();
int j = 0;
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) store(j++, v);
}
realLength = j;
return this;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/** rb_ary_or
*
*/
@JRubyMethod(name = "|", required = 1)
public IRubyObject op_or(IRubyObject other) {
RubyArray ary2 = other.convertToArray();
RubyHash set = makeHash(ary2);
RubyArray ary3 = new RubyArray(getRuntime(), realLength + ary2.realLength);
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (set.fastDelete(v)) ary3.append(v);
}
for (int i = 0; i < ary2.realLength; i++) {
IRubyObject v = ary2.elt(i);
if (set.fastDelete(v)) ary3.append(v);
}
Helpers.fillNil(ary3.values, ary3.realLength, ary3.values.length, getRuntime());
return ary3;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/** rb_ary_or
*
*/
@JRubyMethod(name = "|", required = 1)
public IRubyObject op_or(IRubyObject other) {
RubyArray ary2 = other.convertToArray();
RubyHash set = makeHash(ary2);
RubyArray ary3 = new RubyArray(getRuntime(), realLength + ary2.realLength);
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (set.fastDelete(v)) ary3.append(v);
}
for (int i = 0; i < ary2.realLength; i++) {
IRubyObject v = ary2.elt(i);
if (set.fastDelete(v)) ary3.append(v);
}
Helpers.fillNil(ary3.values, ary3.realLength, ary3.values.length, getRuntime());
return ary3;
}
代码示例来源:origin: org.jruby/jruby-complete
/** rb_ary_or
*
*/
@JRubyMethod(name = "|", required = 1)
public IRubyObject op_or(IRubyObject other) {
Ruby runtime = getRuntime();
RubyArray ary2 = other.convertToArray();
int maxSize = realLength + ary2.realLength;
if (maxSize == 0) return newEmptyArray(runtime);
RubyArray ary3 = newBlankArray(runtime, maxSize);
RubyHash set = makeHash(ary2);
int index = 0;
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (set.fastDelete(v)) ary3.store(index++, v);
}
for (int i = 0; i < ary2.realLength; i++) {
IRubyObject v = ary2.elt(i);
if (set.fastDelete(v)) ary3.store(index++, v);
}
// if index is 1 and we made a size 2 array, repack
if (index == 1 && maxSize == 2) return newArray(runtime, ary3.eltInternal(0));
return ary3;
}
代码示例来源:origin: org.jruby/jruby-core
/** rb_ary_or
*
*/
@JRubyMethod(name = "|", required = 1)
public IRubyObject op_or(IRubyObject other) {
Ruby runtime = getRuntime();
RubyArray ary2 = other.convertToArray();
int maxSize = realLength + ary2.realLength;
if (maxSize == 0) return newEmptyArray(runtime);
RubyArray ary3 = newBlankArray(runtime, maxSize);
RubyHash set = makeHash(ary2);
int index = 0;
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (set.fastDelete(v)) ary3.store(index++, v);
}
for (int i = 0; i < ary2.realLength; i++) {
IRubyObject v = ary2.elt(i);
if (set.fastDelete(v)) ary3.store(index++, v);
}
// if index is 1 and we made a size 2 array, repack
if (index == 1 && maxSize == 2) return newArray(runtime, ary3.eltInternal(0));
return ary3;
}
代码示例来源:origin: org.jruby/jruby-complete
/** rb_ary_uniq
*
*/
public IRubyObject uniq(ThreadContext context) {
RubyHash hash = makeHash();
if (realLength == hash.size()) return makeShared();
RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
int j = 0;
try {
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) result.values[j++] = v;
}
} catch (ArrayIndexOutOfBoundsException ex) {
throw concurrentModification(context.runtime, ex);
}
result.realLength = j;
return result;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/** rb_ary_and
*
*/
@JRubyMethod(name = "&", required = 1)
public IRubyObject op_and(IRubyObject other) {
RubyArray ary2 = other.convertToArray();
RubyHash hash = ary2.makeHash();
RubyArray ary3 = new RubyArray(getRuntime(), realLength < ary2.realLength ? realLength : ary2.realLength);
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) ary3.append(v);
}
Helpers.fillNil(ary3.values, ary3.realLength, ary3.values.length, getRuntime());
return ary3;
}
代码示例来源:origin: org.jruby/jruby-core
/** rb_ary_uniq
*
*/
public IRubyObject uniq(ThreadContext context) {
RubyHash hash = makeHash();
if (realLength == hash.size()) return makeShared();
RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
int j = 0;
try {
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) result.values[j++] = v;
}
} catch (ArrayIndexOutOfBoundsException ex) {
throw concurrentModification(context.runtime, ex);
}
result.realLength = j;
return result;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/** rb_ary_and
*
*/
@JRubyMethod(name = "&", required = 1)
public IRubyObject op_and(IRubyObject other) {
RubyArray ary2 = other.convertToArray();
RubyHash hash = ary2.makeHash();
RubyArray ary3 = new RubyArray(getRuntime(), realLength < ary2.realLength ? realLength : ary2.realLength);
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) ary3.append(v);
}
Helpers.fillNil(ary3.values, ary3.realLength, ary3.values.length, getRuntime());
return ary3;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/** rb_ary_uniq
*
*/
@JRubyMethod(name = "uniq", compat = RUBY1_8)
public IRubyObject uniq(ThreadContext context) {
RubyHash hash = makeHash();
if (realLength == hash.size()) return makeShared();
RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
int j = 0;
try {
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) result.values[j++] = v;
}
} catch (ArrayIndexOutOfBoundsException aioob) {
concurrentModification();
}
result.realLength = j;
return result;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/** rb_ary_uniq
*
*/
@JRubyMethod(name = "uniq", compat = RUBY1_8)
public IRubyObject uniq(ThreadContext context) {
RubyHash hash = makeHash();
if (realLength == hash.size()) return makeShared();
RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
int j = 0;
try {
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) result.values[j++] = v;
}
} catch (ArrayIndexOutOfBoundsException aioob) {
concurrentModification();
}
result.realLength = j;
return result;
}
代码示例来源:origin: org.jruby/jruby-complete
/** rb_ary_and
*
*/
@JRubyMethod(name = "&", required = 1)
public IRubyObject op_and(IRubyObject other) {
Ruby runtime = getRuntime();
RubyArray ary2 = other.convertToArray();
if (realLength == 0 || ary2.realLength == 0) return newEmptyArray(runtime);
int maxSize = realLength < ary2.realLength ? realLength : ary2.realLength;
RubyArray ary3 = newBlankArray(runtime, maxSize);
RubyHash hash = ary2.makeHash();
int index = 0;
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) ary3.store(index++, v);
}
// if index is 1 and we made a size 2 array, repack
if (index == 0) return newEmptyArray(runtime);
if (index == 1 && maxSize == 2) return newArray(runtime, ary3.eltInternal(0));
return ary3;
}
代码示例来源:origin: org.jruby/jruby-core
/** rb_ary_and
*
*/
@JRubyMethod(name = "&", required = 1)
public IRubyObject op_and(IRubyObject other) {
Ruby runtime = getRuntime();
RubyArray ary2 = other.convertToArray();
if (realLength == 0 || ary2.realLength == 0) return newEmptyArray(runtime);
int maxSize = realLength < ary2.realLength ? realLength : ary2.realLength;
RubyArray ary3 = newBlankArray(runtime, maxSize);
RubyHash hash = ary2.makeHash();
int index = 0;
for (int i = 0; i < realLength; i++) {
IRubyObject v = elt(i);
if (hash.fastDelete(v)) ary3.store(index++, v);
}
// if index is 1 and we made a size 2 array, repack
if (index == 0) return newEmptyArray(runtime);
if (index == 1 && maxSize == 2) return newArray(runtime, ary3.eltInternal(0));
return ary3;
}
代码示例来源:origin: org.jruby/jruby-core
hash.fastDelete(runtime.newSymbol("_bc"));
hash.fastDelete(runtime.newSymbol("_comp"));
代码示例来源:origin: org.jruby/jruby-complete
hash.fastDelete(runtime.newSymbol("_bc"));
hash.fastDelete(runtime.newSymbol("_comp"));
内容来源于网络,如有侵权,请联系作者删除!