java.lang.Object
me.sbasalaev.collection.Collection<T>
me.sbasalaev.collection.Set<T>
- All Implemented Interfaces:
Cloneable,Iterable<T>,Traversable<T>
- Direct Known Subclasses:
MutableSet
A collection of distinct elements.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns shallow immutable copy of this set.abstract booleanWhether given element is in this set.static <T> Set<T> empty()Empty set.booleanWhether given object is equal to this set.Returns set that contains only elements of this set satisfying given condition.static <T> Set<T> Set view of given java set.inthashCode()Hash code of the set.Set containing only elements of this set that are also in another set.booleanintersects(Set<?> other) Whether any element of this set is also in the given set.booleanWhether all elements of this set are also in the given set.booleanisSuperset(Set<?> other) Whether all elements of given set are also in this set.<R> Set<R> Returns set with given mapping applied to all elements of this set.static <T> Set<T> of(T... elements) Set containing given elements.Creates aSpliteratorover elements of this collection.toJava()Returns view of this set as Java set.static <T> Set<T> Set containing elements of all given sets.static <T> Set<T> union(Traversable<? extends Set<? extends T>> sets) Set containing elements of all given sets.Set<?> Set containing elements of both this and the other set.Set containing only elements of this set that are not in another set.Methods inherited from class me.sbasalaev.collection.Collection
count, fillArray, isEmpty, nonEmpty, size, stream, toArray, toArray, toList, toSet, toString
-
Constructor Details
-
Set
public Set()Constructor for subclasses.
-
-
Method Details
-
empty
Empty set. -
of
Set containing given elements. When there are duplicate elements according toequals(), only the first of them is put in the resulting set. -
union
Set containing elements of all given sets. This method returns immutable set unaffected by changes to the original sets. -
union
Set containing elements of all given sets. This method returns immutable set unaffected by the changes to the original sets. -
fromJava
Set view of given java set. -
contains
Whether given element is in this set. -
isSuperset
Whether all elements of given set are also in this set. -
isSubset
Whether all elements of this set are also in the given set. -
intersects
Whether any element of this set is also in the given set. -
unite
Set containing elements of both this and the other set. This method returns immutable set unaffected by changes to the original sets. -
intersect
Set containing only elements of this set that are also in another set. This method returns immutable set unaffected by changes to the original sets. -
without
Set containing only elements of this set that are not in another set. This method returns immutable set unaffected by changes to the original sets. -
mapped
Returns set with given mapping applied to all elements of this set. This method returns immutable set unaffected by changes to this set.- Specified by:
mappedin classCollection<T>
-
filtered
Returns set that contains only elements of this set satisfying given condition. This method returns immutable set unaffected by changes to this set.- Specified by:
filteredin classCollection<T>
-
toJava
Returns view of this set as Java set. -
clone
Returns shallow immutable copy of this set. May return itself if this set is immutable.- Specified by:
clonein classCollection<T>
-
spliterator
Description copied from class:CollectionCreates aSpliteratorover elements of this collection. The spliterator reportsSpliterator.NONNULLandSpliterator.SIZED.- Specified by:
spliteratorin interfaceIterable<T>- Specified by:
spliteratorin classCollection<T>
-
equals
Whether given object is equal to this set. Two sets are equal if they contain the same elements, i.e.this.isSuperset(other) && this.isSubset(other)
- Specified by:
equalsin classCollection<T>
-
hashCode
public int hashCode()Hash code of the set. The hash code of the set is a sum of hash codes of its elements.- Specified by:
hashCodein classCollection<T>
-