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

public Class RubySortedSet

extends RubySet
implements SortedSet
Class Inheritance
All Implemented Interfaces
java.util.SortedSet, java.util.SequencedSet, java.util.Set, java.util.Collection, java.lang.Iterable, java.util.SequencedCollection
Annotations
@JRubyClass
name:SortedSet
parent:Set
Imports
org.jruby.*, org.jruby.anno.JRubyMethod, org.jruby.runtime.Arity, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, java.util.*

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static class

Field Summary

Modifier and TypeField and Description
private final TreeSet<IRubyObject>
Inherited from org.jruby.ext.set.RubySet:
hash

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
protected void
public Comparator<? super IRubyObject>
comparator()

Implements java.util.SortedSet.comparator.

Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.

public static RubySortedSet
create(final ThreadContext context, IRubyObject self, IRubyObject... ary)

Hides org.jruby.ext.set.RubySet.create.

Creates a new set containing the given objects.

pack-priv static RubyClass
protected boolean
protected void
protected Set<IRubyObject>
public Object
first()

Implements java.util.SortedSet.first.

Returns the first (lowest) element currently in this set.

public IRubyObject
public SortedSet<E>
headSet(Object
high endpoint (exclusive) of the returned set
toElement
)

Implements java.util.SortedSet.headSet.

Returns a view of the portion of this set whose elements are strictly less than toElement.

public IRubyObject
public IRubyObject
public Iterator<Object>
iterator()

Overrides org.jruby.ext.set.RubySet.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this set.

public Object
last()

Implements java.util.SortedSet.last.

Returns the last (highest) element currently in this set.

public IRubyObject
public SortedSet<IRubyObject>
public SortedSet<IRubyObject>
rawSubSet(IRubyObject fromElement, IRubyObject toElement)

public SortedSet<IRubyObject>
rawTailSet(IRubyObject fromElement)

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

public SortedSet<E>
subSet(Object
low endpoint (inclusive) of the returned set
fromElement
,
Object
high endpoint (exclusive) of the returned set
toElement
)

Implements java.util.SortedSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.

public SortedSet<E>
tailSet(Object
low endpoint (inclusive) of the returned set
fromElement
)

Implements java.util.SortedSet.tailSet.

Returns a view of the portion of this set whose elements are greater than or equal to fromElement.

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

Overrides org.jruby.ext.set.RubySet.to_a.

Converts the set to an array.

pack-priv void
Inherited from org.jruby.ext.set.RubySet:
addaddadd_paddAlladdImplallocHashallocHashallocHashclassifyclearclearclearImplcollect_bangcompare_by_identitycompare_by_identity_pcontainscontainsAllcontainsImplcreateSetClassdeletedelete_ifdelete_pdisjoint_pdivideeachelementsempty_peqlflattenflatten_bangflatten_mergefreezegetTSorthashinclude_pinitializeinitializeinitializeinitSetinspectinstance_variable_setintersectintersect_pinvokeAddisEmptyjoinjoinkeep_iflengthmodifyCheckmodifyChecknewSetnewSetnewSetFastop_andop_cmpop_diffop_eqlop_equalop_orop_xorproper_subset_pproper_superset_prawIteratorrb_clearrb_mergerb_mergereject_bangremoveremoveAllreplaceresetretainAllselect_bangsetHashsizesubset_psubtractsuperset_ptaintto_setto_settoArraytoArraytoRubytoRubyuntaint

Field Detail

orderback to summary
private final TreeSet<IRubyObject> order

Constructor Detail

RubySortedSetback to summary
protected RubySortedSet(Ruby runtime, RubyClass klass)

Method Detail

addImplback to summary
protected void addImpl(ThreadContext context, final IRubyObject obj)

Overrides org.jruby.ext.set.RubySet.addImpl.

Annotations
@Override
addImplSetback to summary
protected void addImplSet(final ThreadContext context, final RubySet set)

Overrides org.jruby.ext.set.RubySet.addImplSet.

Annotations
@Override
clearImplback to summary
protected void clearImpl(ThreadContext context)

Overrides org.jruby.ext.set.RubySet.clearImpl.

Annotations
@Override
comparatorback to summary
public Comparator<? super IRubyObject> comparator()

Implements java.util.SortedSet.comparator.

Doc from java.util.SortedSet.comparator.

Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.

Returns:Comparator<? super IRubyObject>

the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements

createback to summary
public static RubySortedSet create(final ThreadContext context, IRubyObject self, IRubyObject... ary)

Hides org.jruby.ext.set.RubySet.create.

Doc from org.jruby.ext.set.RubySet.create.

Creates a new set containing the given objects.

Annotations
@JRubyMethod
name:[]
rest:true
meta:true
createSortedSetClassback to summary
pack-priv static RubyClass createSortedSetClass(ThreadContext context, RubyClass Set)
deleteImplback to summary
protected boolean deleteImpl(final IRubyObject obj)

Overrides org.jruby.ext.set.RubySet.deleteImpl.

Annotations
@Override
deleteImplIteratorback to summary
protected void deleteImplIterator(final IRubyObject obj, final Iterator<E> it)

Overrides org.jruby.ext.set.RubySet.deleteImplIterator.

Annotations
@Override
elementsOrderedback to summary
protected Set<IRubyObject> elementsOrdered()

Overrides org.jruby.ext.set.RubySet.elementsOrdered.

Annotations
@Override
firstback to summary
public Object first()

Implements java.util.SortedSet.first.

Doc from java.util.SortedSet.first.

Returns the first (lowest) element currently in this set.

Returns:Object

the first (lowest) element currently in this set

firstValueback to summary
public IRubyObject firstValue()
headSetback to summary
public SortedSet<E> headSet(Object toElement)

Implements java.util.SortedSet.headSet.

Doc from java.util.SortedSet.headSet.

Returns a view of the portion of this set whose elements are strictly less than toElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
toElement:Object

high endpoint (exclusive) of the returned set

Returns:SortedSet<E>

a view of the portion of this set whose elements are strictly less than toElement

initialize_cloneback to summary
public IRubyObject initialize_clone(ThreadContext context, IRubyObject[] args)

Overrides org.jruby.ext.set.RubySet.initialize_clone.

Annotations
@JRubyMethod
frame:true
keywords:true
required:1
optional:1
checkArity:false
initialize_dupback to summary
public IRubyObject initialize_dup(ThreadContext context, IRubyObject orig)

Overrides org.jruby.ext.set.RubySet.initialize_dup.

Annotations
@Override
iteratorback to summary
public Iterator<Object> iterator()

Overrides org.jruby.ext.set.RubySet.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Doc from java.util.Set.iterator.

Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Returns:Iterator<Object>

an iterator over the elements in this set

Annotations
@Override
lastback to summary
public Object last()

Implements java.util.SortedSet.last.

Doc from java.util.SortedSet.last.

Returns the last (highest) element currently in this set.

Returns:Object

the last (highest) element currently in this set

lastValueback to summary
public IRubyObject lastValue()
rawHeadSetback to summary
public SortedSet<IRubyObject> rawHeadSet(IRubyObject toElement)
rawSubSetback to summary
public SortedSet<IRubyObject> rawSubSet(IRubyObject fromElement, IRubyObject toElement)
rawTailSetback to summary
public SortedSet<IRubyObject> rawTailSet(IRubyObject fromElement)
sortback to summary
public RubyArray<T extends IRubyObject> sort(final ThreadContext context)
Annotations
@JRubyMethod
name:sort
subSetback to summary
public SortedSet<E> subSet(Object fromElement, Object toElement)

Implements java.util.SortedSet.subSet.

Doc from java.util.SortedSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned set is empty.) The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
fromElement:Object

low endpoint (inclusive) of the returned set

toElement:Object

high endpoint (exclusive) of the returned set

Returns:SortedSet<E>

a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive

tailSetback to summary
public SortedSet<E> tailSet(Object fromElement)

Implements java.util.SortedSet.tailSet.

Doc from java.util.SortedSet.tailSet.

Returns a view of the portion of this set whose elements are greater than or equal to fromElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
fromElement:Object

low endpoint (inclusive) of the returned set

Returns:SortedSet<E>

a view of the portion of this set whose elements are greater than or equal to fromElement

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

Overrides org.jruby.ext.set.RubySet.to_a.

Doc from org.jruby.ext.set.RubySet.to_a.

Converts the set to an array. The order of elements is uncertain.

Annotations
@Override
unmarshalback to summary
pack-priv void unmarshal()

Overrides org.jruby.ext.set.RubySet.unmarshal.

Annotations
@Override
org.jruby.ext.set back to summary

private Class RubySortedSet.JavaIterator

extends Object
implements Iterator<Object>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private final Iterator<IRubyObject>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public Object
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

rawIteratorback to summary
private final Iterator<IRubyObject> rawIterator

Constructor Detail

JavaIteratorback to summary
pack-priv JavaIterator()

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public Object next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Object

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
org.jruby.ext.set back to summary

private Class RubySortedSet.OrderComparator

extends DefaultComparator
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Ruby

Constructor Summary

AccessConstructor and Description
pack-priv
OrderComparator(final Ruby runtime)

Method Summary

Modifier and TypeMethod and Description
public int
compare(IRubyObject
the first object to be compared.
obj1
,
IRubyObject
the second object to be compared.
obj2
)

Overrides org.jruby.RubyArray.DefaultComparator.compare.

Implements java.util.Comparator.compare.

Compares its two arguments for order.

protected ThreadContext
Inherited from org.jruby.RubyArray.DefaultComparator:
compareGenericcompareGenericcompareGenericcompareIntegercompareString

Field Detail

runtimeback to summary
private final Ruby runtime

Constructor Detail

OrderComparatorback to summary
pack-priv OrderComparator(final Ruby runtime)

Method Detail

compareback to summary
public int compare(IRubyObject obj1, IRubyObject obj2)

Overrides org.jruby.RubyArray.DefaultComparator.compare.

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
obj1:IRubyObject

the first object to be compared.

obj2:IRubyObject

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

contextback to summary
protected ThreadContext context()

Overrides org.jruby.RubyArray.DefaultComparator.context.

Annotations
@Override