@Override public final RubyBoolean include_p(ThreadContext context, IRubyObject item) { return context.runtime.newBoolean(containsString(convertToString(item))); }
protected void addFeatureToIndex(String shortName, String name) { loadedFeaturesDup = (RubyArray)loadedFeatures.dup(); loadedFeaturesIndex.put(shortName, name); }
@Override public synchronized RubyArray collectBang(ThreadContext context, Block block) { RubyArray result = super.collectBang(context, block); rehash(); return result; }
private void rehash() { set.clear(); addAll(toJavaArrayMaybeUnsafe()); }
@Override public synchronized IRubyObject delete(ThreadContext context, IRubyObject item, Block block) { IRubyObject result = super.delete(context, item, block); if ( ! includes(context, item) ) set.remove(convertToString(item)); // in case there's a duplicity return result; }
public boolean featureAlreadyLoaded(String name) { if (loadedFeatures.containsString(name)) return true; // Bail if our features index fell out of date. if (!isFeaturesIndexUpToDate()) { loadedFeaturesIndex.clear(); return false; } return isFeatureInIndex(name); }
loadedFeatures = new StringArraySet(runtime);
private void addAll(IRubyObject[] items) { for (IRubyObject item : items) { set.add(convertToString(item)); } }
@Override public synchronized IRubyObject unshift(IRubyObject[] items) { IRubyObject result = super.unshift(items); addAll(items); return result; }
@Override public synchronized RubyArray push(IRubyObject item) { RubyArray result = super.push(item); add(item); return result; }
protected void addLoadedFeature(String shortName, String name) { loadedFeatures.appendString(runtime, name); addFeatureToIndex(shortName, name); }
protected void addLoadedFeature(String shortName, String name) { loadedFeatures.append(RubyString.newString(runtime, name)); addFeatureToIndex(shortName, name); }
public void removeInternalLoadedFeature(String name) { RubyString nameRubyString = runtime.newString(name); loadedFeatures.delete(runtime.getCurrentContext(), nameRubyString, Block.NULL_BLOCK); }
public boolean featureAlreadyLoaded(String name) { if (loadedFeatures.containsString(name)) return true; // Bail if our features index fell out of date. if (!isFeaturesIndexUpToDate()) { loadedFeaturesIndex.clear(); return false; } return isFeatureInIndex(name); }
loadedFeatures = new StringArraySet(runtime);
@Override public synchronized IRubyObject delete(ThreadContext context, IRubyObject item, Block block) { IRubyObject result = super.delete(context, item, block); if ( ! includes(context, item) ) set.remove(convertToString(item)); // in case there's a duplicity return result; }
private void rehash() { set.clear(); addAll(toJavaArrayMaybeUnsafe()); }
private void addAll(IRubyObject[] items) { for (IRubyObject item : items) { set.add(convertToString(item)); } }
@Override public synchronized IRubyObject unshift(IRubyObject[] items) { IRubyObject result = super.unshift(items); addAll(items); return result; }
@Override public synchronized IRubyObject unshift(IRubyObject item) { IRubyObject result = super.unshift(item); add(item); return result; }