E
- the type of the elementspublic final class RubySet<E> extends RubyEnumerable<E> implements java.util.Set<E>, java.lang.Comparable<java.util.Set<E>>, java.io.Serializable
RubySet
implements all methods refer to the Set class of Ruby
language.
RubySet
is also a Java Set and a Ruby.Enumerable
.
Constructor and Description |
---|
RubySet()
Creates a
RubySet . |
RubySet(java.lang.Iterable<E> iter)
Creates a
RubySet by given Set. |
RubySet(java.util.LinkedHashSet<E> set)
Creates a
RubySet by given LinkedHashSet. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
boolean |
addAll(java.util.Collection<? extends E> c) |
RubySet<E> |
addʔ(E e)
Adds the given object to the set and returns self.
|
<S> RubyHash<S,RubySet<E>> |
classify(TransformBlock<? super E,? extends S> block)
Classifies the set by the return value of the given block and returns a
RubyHash of {S value => RubySet<E>} pairs. |
void |
clear() |
RubySet<E> |
collectǃ(java.lang.String methodName,
java.lang.Object... args)
Transforms each element by given method name in self.
|
RubySet<E> |
collectǃ(TransformBlock<? super E,? extends E> block)
Replaces the elements with ones returned by
RubyEnumerable.collect(TransformBlock) . |
int |
compareTo(java.util.Set<E> arg0) |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
static <E> RubySet<E> |
copyOf(java.lang.Iterable<E> elements)
Returns a
RubySet which copies the elements of given Iterable. |
RubySet<E> |
delete(E e)
Deletes the given object from the set and returns self.
|
RubySet<E> |
deleteIf(BooleanBlock<? super E> block)
Deletes every element of the set for which block evaluates to true, and
returns self.
|
RubySet<E> |
deleteʔ(E e)
Deletes the given object from the set and returns self.
|
RubySet<E> |
difference(java.lang.Iterable<E> iter)
Returns a new set built by duplicating the set, removing every element that
appears in the given Iterable.
|
boolean |
disjointʔ(java.lang.Iterable<E> iter)
Returns true if the set and the given Iterable have no element in common.
|
<S> RubySet<RubySet<E>> |
divide(TransformBlock<? super E,? extends S> block)
Divides the set into a set of subsets according to the commonality defined
by the given block.
|
RubySet<E> |
each(Block<? super E> block)
Yields each element to the block.
|
boolean |
emptyʔ()
Returns true if the set contains no elements.
|
boolean |
equals(java.lang.Object o) |
RubySet<E> |
exclusive(java.lang.Iterable<E> iter)
Returns a new set containing elements exclusive between the set and the
given Iterable.
|
<S> RubySet<S> |
flatten()
Returns a new set that is a copy of the set, flattening each containing set
recursively.
|
RubySet<E> |
freeze()
Freezes this
RubySet . |
boolean |
frozenʔ()
Checks if this
RubySet is frozen. |
protected java.lang.Iterable<E> |
getIterable()
Returns an Iterable of elements.
|
int |
hashCode() |
java.lang.String |
inspect()
Equivalent to
toString() . |
RubySet<E> |
intersection(java.lang.Iterable<E> iter)
Returns a new set containing elements common to the set and the given
Iterable.
|
boolean |
intersectʔ(java.lang.Iterable<E> iter)
Returns true if the set and the given Iterable have at least one element in
common.
|
boolean |
isEmpty() |
RubySet<E> |
keepIf(BooleanBlock<? super E> block)
Deletes every element of the set for which block evaluates to false, and
returns self.
|
int |
length()
Equivalent to
size() . |
RubySet<E> |
mapǃ(java.lang.String methodName,
java.lang.Object... args)
Equivalent to
collectǃ(String, Object...) . |
RubySet<E> |
mapǃ(TransformBlock<? super E,? extends E> block)
Equivalent to
collectǃ(TransformBlock) . |
RubySet<E> |
merge(java.lang.Iterable<E> iter)
Merges the elements of the given Iterable to the set and returns self.
|
static <E> RubySet<E> |
of(java.util.LinkedHashSet<E> set)
Returns a
RubySet which wraps the given LinkedHashSet. |
boolean |
properSubsetʔ(java.util.Set<E> set)
Returns true if the set is a proper subset of the given set.
|
boolean |
properSupersetʔ(java.util.Set<E> set)
Returns true if the set is a proper superset of the given set.
|
RubySet<E> |
rejectǃ(BooleanBlock<? super E> block)
Equivalent to
deleteIf(BooleanBlock) , but returns null if no
changes were made. |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
RubySet<E> |
replace(java.lang.Iterable<E> iter)
Replaces the contents of the set with the contents of the given Iterable
and returns self.
|
boolean |
retainAll(java.util.Collection<?> c) |
RubySet<E> |
selectǃ(BooleanBlock<? super E> block)
Equivalent to
keepIf(BooleanBlock) , but returns null if no changes
were made. |
int |
size() |
boolean |
subsetʔ(java.util.Set<E> set)
Returns true if the set is a subset of the given set.
|
RubySet<E> |
subtract(java.lang.Iterable<E> iter)
Deletes every element that appears in the given Iterable and returns self.
|
boolean |
supersetʔ(java.util.Set<E> set)
Returns true if the set is a superset of the given set.
|
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
java.lang.String |
toString() |
RubySet<E> |
union(java.lang.Iterable<E> iter)
Returns a new set built by merging the set and the elements of the given
Iterable.
|
allʔ, allʔ, anyʔ, anyʔ, chunk, chunk, collect, collect, collect, collectConcat, collectConcat, count, count, cycle, cycle, cycle, cycle, detect, detect, drop, dropWhile, dropWhile, each, eachCons, eachCons, eachEntry, eachEntry, eachSlice, eachSlice, eachWithIndex, eachWithIndex, eachWithObject, eachWithObject, entries, find, find, findAll, findAll, findIndex, findIndex, findIndex, first, first, flatMap, flatMap, grep, grep, grep, groupBy, groupBy, groupBy, includeʔ, inject, inject, inject, inject, iterator, lazy, map, map, map, max, max, maxBy, maxBy, maxBy, maxBy, memberʔ, min, min, minBy, minBy, minBy, minBy, minmax, minmax, minmaxBy, minmaxBy, minmaxBy, minmaxBy, noneʔ, noneʔ, oneʔ, oneʔ, partition, partition, reduce, reduce, reduce, reduce, reject, reject, reverseEach, reverseEach, select, select, sliceBefore, sliceBefore, sort, sortBy, sortBy, sortBy, sortBy, sortBy, take, takeWhile, takeWhile, toA, zip, zip, zip
public RubySet()
RubySet
.public RubySet(java.util.LinkedHashSet<E> set)
RubySet
by given LinkedHashSet. It's a wrapper
implementation. No defensive copy has been made.set
- any LinkedHashSetjava.lang.NullPointerException
- if set is nullpublic static <E> RubySet<E> of(java.util.LinkedHashSet<E> set)
RubySet
which wraps the given LinkedHashSet.set
- any LinkedHashSetRubySet
java.lang.NullPointerException
- if set is nullpublic static <E> RubySet<E> copyOf(java.lang.Iterable<E> elements)
RubySet
which copies the elements of given Iterable.elements
- any IterableRubySet
java.lang.NullPointerException
- if elements is nullprotected java.lang.Iterable<E> getIterable()
RubyEnumerable
getIterable
in class RubyEnumerable<E>
public RubySet<E> addʔ(E e)
e
- an elementRubySet
or nullpublic <S> RubyHash<S,RubySet<E>> classify(TransformBlock<? super E,? extends S> block)
RubyHash
of {S value => RubySet<E>} pairs.block
- to transform elementsRubyHash
public RubySet<E> collectǃ(TransformBlock<? super E,? extends E> block)
RubyEnumerable.collect(TransformBlock)
.block
- to transform elementsRubySet
public RubySet<E> collectǃ(java.lang.String methodName, java.lang.Object... args)
methodName
- name of a Methodargs
- arguments of a MethodRubySet
public RubySet<E> delete(E e)
e
- an elementRubySet
public RubySet<E> deleteʔ(E e)
e
- an elementRubySet
or nullpublic RubySet<E> deleteIf(BooleanBlock<? super E> block)
block
- to filter elementsRubySet
public RubySet<E> difference(java.lang.Iterable<E> iter)
iter
- an IterableRubySet
public boolean disjointʔ(java.lang.Iterable<E> iter)
iter
- an Iterablepublic <S> RubySet<RubySet<E>> divide(TransformBlock<? super E,? extends S> block)
public RubySet<E> each(Block<? super E> block)
each
in interface Ruby.Enumerable<E>
each
in interface RubyContract.Enumerable<E,Ruby.Enumerator<?>,RubyArray<?>>
each
in class RubyEnumerable<E>
block
- to yield each elementRubySet
public boolean emptyʔ()
public RubySet<E> exclusive(java.lang.Iterable<E> iter)
iter
- an IterableRubySet
public <S> RubySet<S> flatten()
RubySet
public boolean frozenʔ()
RubySet
is frozen.RubySet
is frozen, false otherwisepublic java.lang.String inspect()
toString()
.public boolean intersectʔ(java.lang.Iterable<E> iter)
public RubySet<E> intersection(java.lang.Iterable<E> iter)
iter
- an IterableRubySet
public RubySet<E> keepIf(BooleanBlock<? super E> block)
block
- to filter elementsRubySet
public RubySet<E> mapǃ(TransformBlock<? super E,? extends E> block)
collectǃ(TransformBlock)
.block
- to transform elementsRubySet
public RubySet<E> mapǃ(java.lang.String methodName, java.lang.Object... args)
collectǃ(String, Object...)
.methodName
- name of a Methodargs
- arguments of a MethodRubySet
public RubySet<E> merge(java.lang.Iterable<E> iter)
iter
- an IterableRubySet
public boolean properSubsetʔ(java.util.Set<E> set)
set
- any Setpublic boolean properSupersetʔ(java.util.Set<E> set)
set
- any Setpublic RubySet<E> rejectǃ(BooleanBlock<? super E> block)
deleteIf(BooleanBlock)
, but returns null if no
changes were made.block
- to transform elementsRubySet
or nullpublic RubySet<E> replace(java.lang.Iterable<E> iter)
iter
- an IterableRubySet
public RubySet<E> selectǃ(BooleanBlock<? super E> block)
keepIf(BooleanBlock)
, but returns null if no changes
were made.block
- to transform elementsRubySet
or nullpublic boolean subsetʔ(java.util.Set<E> set)
set
- any Setpublic RubySet<E> subtract(java.lang.Iterable<E> iter)
iter
- an IterableRubySet
public boolean supersetʔ(java.util.Set<E> set)
set
- any Setpublic RubySet<E> union(java.lang.Iterable<E> iter)
iter
- an IterableRubySet
public boolean add(E e)
public boolean addAll(java.util.Collection<? extends E> c)
public void clear()
public boolean contains(java.lang.Object o)
public boolean containsAll(java.util.Collection<?> c)
public boolean isEmpty()
public boolean remove(java.lang.Object o)
public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
public int size()
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
public boolean equals(java.lang.Object o)
public int hashCode()
public java.lang.String toString()
toString
in class RubyEnumerable<E>