Top Description Inners Fields Constructors Methods
org.jruby.ext.set

public Class RubySet

extends RubyObject
implements Set
Class Inheritance
All Implemented Interfaces
java.util.Set, java.util.Collection, java.lang.Iterable
Known Direct Subclasses
org.jruby.ext.set.RubySortedSet
Annotations
@JRubyClass
name:Set
include:Enumerable
Imports
org.jcodings.specific.USASCIIEncoding, org.jruby.*, .RubyEnumerator.SizeFn, org.jruby.anno.JRubyMethod, org.jruby.api.Access, org.jruby.javasupport.JavaUtil, org.jruby.runtime.*, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.marshal.MarshalDumper, .MarshalLoader, org.jruby.util.ArraySupport, org.jruby.util.io.RubyInputStream, .RubyOutputStream, java.io.IOException, java.lang.reflect.Array, java.util.Collection, .IdentityHashMap, .Iterator, .Set

Native implementation of Ruby's Set (set.rb replacement).
Author
kares

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
private abstract static class
private static class

Field Summary

Modifier and TypeField and Description
pack-priv RubyHash
private static final byte[]
Inherited from org.jruby.RubyObject:
IVAR_INSPECTING_OBJECT_ALLOCATOROBJECT_ALLOCATORREIFYING_OBJECT_ALLOCATOR

Constructor Summary

AccessConstructor and Description
protected
RubySet(Ruby runtime, RubyClass klass)

Method Summary

Modifier and TypeMethod and Description
public RubySet
add(final ThreadContext context, IRubyObject obj)

Adds the given object to the set and returns self.

public boolean
add(Object
element to be added to this set
element
)

Implements java.util.Set.add.

Adds the specified element to this set if it is not already present (optional operation).

public IRubyObject
add_p(final ThreadContext context, IRubyObject obj)

Adds the given object to the set and returns self.

public boolean
addAll(Collection<E>
collection containing elements to be added to this set
coll
)

Implements java.util.Set.addAll.

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

private void
addFlattened(final ThreadContext context, final IdentityHashMap<K, V> seen, IRubyObject e)

protected void
addImpl(final Ruby runtime, final IRubyObject obj)
Deprecated since 10.0.

protected void
addImpl(final ThreadContext context, final IRubyObject obj)

protected void
addImplSet(final ThreadContext context, final RubySet set)

private boolean
pack-priv final void
allocHash(final ThreadContext context)

pack-priv final void
allocHash(final Ruby runtime)

pack-priv final void
allocHash(final ThreadContext context, final int size)

public IRubyObject
classify(ThreadContext context, final Block block)

public void
clear()

Implements java.util.Set.clear.

Removes all of the elements from this set (optional operation).

public void
protected void
clearImpl()
Deprecated since 10.0.

protected void
public IRubyObject
collect_bang(final ThreadContext context, Block block)

public IRubyObject
public IRubyObject
public boolean
contains(Object
element whose presence in this set is to be tested
o
)

Implements java.util.Set.contains.

Returns true if this set contains the specified element.

public boolean
containsAll(Collection<E>
collection to be checked for containment in this set
coll
)

Implements java.util.Set.containsAll.

Returns true if this set contains all of the elements of the specified collection.

pack-priv final boolean
public static RubySet
create(final ThreadContext context, IRubyObject self, IRubyObject... ary)

Creates a new set containing the given objects.

pack-priv static RubyClass
createSetClass(ThreadContext context, RubyClass Object, RubyModule Enumerable)

public IRubyObject
delete(final ThreadContext context, IRubyObject obj)

public IRubyObject
delete_if(final ThreadContext context, Block block)

public IRubyObject
delete_p(final ThreadContext context, IRubyObject obj)

Deletes the given object from the set and returns self.

protected boolean
protected void
deleteImplIterator(final IRubyObject obj, final Iterator<E> it)

public IRubyObject
disjoint_p(final ThreadContext context, IRubyObject setArg)

Returns true if the set and the given set have no element in common.

public IRubyObject
divide(ThreadContext context, final Block block)

Divides the set into a set of subsets according to the commonality defined by the given block.

private IRubyObject
divideTSort(ThreadContext context, final Block block)

private static IRubyObject
doWithEnum(final ThreadContext context, final IRubyObject enume, final RubySet.EachBody blockImpl)

public IRubyObject
each(final ThreadContext context, Block block)

protected final Set<IRubyObject>
protected Set<IRubyObject>
public IRubyObject
public boolean
eql(IRubyObject otherArg)

Overrides org.jruby.RubyBasicObject.eql.

Implements org.jruby.runtime.builtin.IRubyObject.eql.

method used for Hash key comparison (specialized for String, Symbol and Fixnum)

public RubySet
flatten(final ThreadContext context)

public IRubyObject
flatten_bang(final ThreadContext context)

public RubySet
private void
flattenMerge(final ThreadContext context, final IRubyObject setArg, final IdentityHashMap<K, V> seen)

public IRubyObject
pack-priv static RubyModule
public RubyFixnum
hash(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyBasicObject.hash.

Will return the hash code of this object.

public RubyBoolean
include_p(final ThreadContext context, IRubyObject obj)

Returns true if the set contains the given object.

public IRubyObject
initialize(ThreadContext context, Block block)

initialize(enum = nil, &block)

public IRubyObject
initialize(ThreadContext context, IRubyObject enume, Block block)

initialize(enum = nil, &block)

protected IRubyObject
initialize(ThreadContext context, IRubyObject[] args, Block block)

public IRubyObject
public IRubyObject
pack-priv final RubySet
initSet(final ThreadContext context, final IRubyObject[] elements, final int off, final int len)

private IRubyObject
initWithEnum(final ThreadContext context, final IRubyObject enume, final Block block)

public RubyString
inspect(ThreadContext context)

Overrides org.jruby.RubyBasicObject.inspect.

Overrides default org.jruby.runtime.builtin.IRubyObject.inspect.

Returns a string containing a human-readable representation of obj.

private RubyString
private static RubyString
inspectPrefix(ThreadContext context, final RubyString str, final RubyClass metaClass)

private RubyString
private void
inspectSet(final ThreadContext context, final RubyString str)

public IRubyObject
instance_variable_set(IRubyObject
of ivar
name
,
IRubyObject
to set
value
)

Overrides org.jruby.RubyBasicObject.instance_variable_set.

rb_obj_ivar_set call-seq: obj.instance_variable_set(symbol, obj) => obj Sets the instance variable names by symbol to object, thereby frustrating the efforts of the class's author to attempt to provide proper encapsulation.

public boolean
intersect(final RubySet set)

public IRubyObject
intersect_p(final ThreadContext context, IRubyObject setArg)

Returns true if the set and the given set have at least one element in common.

pack-priv IRubyObject
invokeAdd(final ThreadContext context, final IRubyObject val)

public boolean
isEmpty()

Implements java.util.Set.isEmpty.

Returns true if this set contains no elements.

public Iterator<Object>
iterator()

Implements java.util.Set.iterator.

Returns an iterator over the elements in this set.

public IRubyObject
public IRubyObject
public IRubyObject
keep_if(final ThreadContext context, Block block)

public IRubyObject
protected final void
modifyCheck(final Ruby runtime)
Deprecated

protected final void
modifyCheck(final ThreadContext context)

public static RubySet

Returns:

a new Set
newSet
(final Ruby
the current runtime
runtime
)

Construct a new Set.

public static RubySet

Returns:

a new Set
newSet
(final Ruby
the current runtime
runtime
,
final RubyClass
the class to assign to the new set
metaclass
)

Construct a new Set.

private static RubySet
newSet(final ThreadContext context, final RubyClass metaClass, final RubyArray<T extends IRubyObject> elements)

pack-priv RubySet

Returns:

a new Set
newSetFast
(final Ruby
the current runtime
runtime
)

Construct a new Set with the same class as this one.

public IRubyObject
op_and(final ThreadContext context, IRubyObject enume)

Returns a new set built by merging the set and the elements of the given enumerable object.

public IRubyObject
public IRubyObject
op_diff(final ThreadContext context, IRubyObject enume)

Returns a new set built by duplicating the set, removing every element that appears in the given enumerable object.

public IRubyObject
public IRubyObject
op_equal(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyBasicObject.op_equal.

Implements org.jruby.runtime.builtin.IRubyObject.op_equal.

rb_obj_equal Will by default use identity equality to compare objects.

public IRubyObject
op_or(final ThreadContext context, IRubyObject enume)

Returns a new set built by merging the set and the elements of the given enumerable object.

public IRubyObject
op_xor(final ThreadContext context, IRubyObject enume)

Returns a new set containing elements exclusive between the set and the given enumerable object.

public IRubyObject
proper_subset_p(final ThreadContext context, IRubyObject setArg)

public IRubyObject
public Iterator<IRubyObject>
public IRubyObject
public RubySet
rb_merge(final ThreadContext context, IRubyObject enume)

public RubySet
rb_merge(final ThreadContext context, IRubyObject... args)

Merges the elements of the given enumerable object to the set and returns self.

public IRubyObject
reject_bang(final ThreadContext context, Block block)

public boolean
remove(Object
object to be removed from this set, if present
element
)

Implements java.util.Set.remove.

Removes the specified element from this set if it is present (optional operation).

public boolean
removeAll(Collection<E>
collection containing elements to be removed from this set
coll
)

Implements java.util.Set.removeAll.

Removes from this set all of its elements that are contained in the specified collection (optional operation).

public RubySet
replace(final ThreadContext context, IRubyObject enume)

Replaces the contents of the set with the contents of the given enumerable object and returns self.

public IRubyObject
public boolean
retainAll(Collection<E>
collection containing elements to be retained in this set
coll
)

Implements java.util.Set.retainAll.

Retains only the elements in this set that are contained in the specified collection (optional operation).

public IRubyObject
select_bang(final ThreadContext context, Block block)

pack-priv final void
setHash(final RubyHash hash)

private static JavaSites.SetSites
sites(ThreadContext context)

Hides org.jruby.RubyObject.sites.

Retrieve the call sites for this class.

private static IRubyObject
size(ThreadContext context, RubySet recv, IRubyObject[] args)

A size method suitable for lambda method reference implementation of SizeFn#size(ThreadContext, IRubyObject, IRubyObject[])

public int
size()

Implements java.util.Set.size.

Returns the number of elements in this set (its cardinality).

public IRubyObject
subset_p(final ThreadContext context, IRubyObject setArg)

public IRubyObject
subtract(final ThreadContext context, IRubyObject enume)

Deletes every element that appears in the given enumerable object and returns self.

public IRubyObject
superset_p(final ThreadContext context, IRubyObject setArg)

public IRubyObject
taint(ThreadContext context)

Overrides org.jruby.RubyBasicObject.taint.

Deprecated

public RubyArray<T extends IRubyObject>
to_a(final ThreadContext context)

Overrides org.jruby.RubyBasicObject.to_a.

Converts the set to an array.

public RubySet
to_set(final ThreadContext context, final Block block)

public RubySet
to_set(final ThreadContext context, final IRubyObject[] args, final Block block)

public Object[]
toArray()

Implements java.util.Set.toArray.

Returns an array containing all of the elements in this set.

public Object[]
toArray(final Object[]
the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
ary
)

Implements java.util.Set.toArray.

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.

pack-priv static IRubyObject
toRuby(Ruby runtime, Object obj)

pack-priv final IRubyObject
pack-priv void
public IRubyObject
Inherited from org.jruby.RubyObject:
attachToObjectSpacecallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitconvertToTypedigdig1dig2eqlInternalequalInternalequalsfinishObjectClassgetNativeClassIndexhashCodeinspectop_eqqputsspecificEvaltoRubyStringtoString