public abstract class Set<A>
extends java.lang.Object
implements java.lang.Iterable<A>
Modifier and Type | Method and Description |
---|---|
<B> Set<B> |
bind(Ord<B> o,
F<A,Set<B>> f)
Binds the given function across this set.
|
F<A,F<Set<A>,Set<A>>> |
delete()
First-class deletion function.
|
Set<A> |
delete(A a)
Deletes the given element from this set.
|
static <A> Set<A> |
empty(Ord<A> ord)
The empty set.
|
Set<A> |
filter(F<A,java.lang.Boolean> f)
Filters elements from this set by returning only elements which produce
true
when the given function is applied to them. |
<B> B |
foldMap(F<A,B> f,
Monoid<B> m)
Folds this Set using the given monoid.
|
static <A> F<A,F<Set<A>,Set<A>>> |
insert()
First-class insertion function.
|
Set<A> |
insert(A x)
Inserts the given element into this set.
|
static <A> F<Set<A>,F<Set<A>,Set<A>>> |
intersect()
A first class function for
intersect(Set) . |
Set<A> |
intersect(Set<A> s)
Remove all elements from this set that do not occur in the given set.
|
boolean |
isEmpty() |
static <A> Set<A> |
iterableSet(Ord<A> o,
java.lang.Iterable<A> as)
Return the elements of the given iterable as a set.
|
java.util.Iterator<A> |
iterator()
Returns an iterator over this set.
|
static <A> Set<A> |
join(Ord<A> o,
Set<Set<A>> s)
Join a set of sets into a single set.
|
<B> Set<B> |
map(Ord<B> o,
F<A,B> f)
Maps the given function across this set.
|
static <A> F<Set<A>,F<A,java.lang.Boolean>> |
member()
First-class membership check.
|
boolean |
member(A x)
Checks if the given element is a member of this set.
|
static <A> F<Set<A>,F<Set<A>,Set<A>>> |
minus()
A first class function for
minus(Set) . |
Set<A> |
minus(Set<A> s)
Remove all elements from this set that occur in the given set.
|
Ord<A> |
ord()
Returns the order of this Set.
|
static <A> Set<A> |
set(Ord<A> o,
A... as)
Constructs a set from the given elements.
|
static <A> Set<A> |
single(Ord<A> o,
A a)
Returns a set with a single element.
|
int |
size()
Returns the size of this set.
|
P3<Set<A>,Option<A>,Set<A>> |
split(A a)
Splits this set at the given element.
|
boolean |
subsetOf(Set<A> s)
Returns true if this set is a subset of the given set.
|
List<A> |
toList()
Returns a list representation of this set.
|
Stream<A> |
toStream()
Returns a stream representation of this set.
|
static <A> F<Set<A>,F<Set<A>,Set<A>>> |
union()
A first class function for
union(Set) . |
Set<A> |
union(Set<A> s)
Add all the elements of the given set to this set.
|
P2<java.lang.Boolean,Set<A>> |
update(A a,
F<A,A> f)
Updates, with the given function, the first element in the set that is equal to the given element,
according to the order.
|
public final boolean isEmpty()
public final P2<java.lang.Boolean,Set<A>> update(A a, F<A,A> f)
a
- An element to replace.f
- A function to transforms the found element.public static <A> Set<A> empty(Ord<A> ord)
ord
- An order for the type of elements.public final boolean member(A x)
x
- An element to check for membership in this set.public static <A> F<Set<A>,F<A,java.lang.Boolean>> member()
public final Set<A> insert(A x)
x
- An element to insert into this set.public static <A> F<A,F<Set<A>,Set<A>>> insert()
public final java.util.Iterator<A> iterator()
iterator
in interface java.lang.Iterable<A>
public static <A> Set<A> single(Ord<A> o, A a)
o
- An order for the type of element.a
- An element to put in a set.public final <B> Set<B> map(Ord<B> o, F<A,B> f)
o
- An order for the elements of the new set.f
- A function to map across this set.public final <B> B foldMap(F<A,B> f, Monoid<B> m)
f
- A transformation from this Set's elements, to the monoid.m
- The monoid to fold this Set with.public final List<A> toList()
public final Stream<A> toStream()
public final <B> Set<B> bind(Ord<B> o, F<A,Set<B>> f)
o
- An order for the elements of the target set.f
- A function to bind across this set.public final Set<A> union(Set<A> s)
s
- A set to add to this set.public static <A> F<Set<A>,F<Set<A>,Set<A>>> union()
union(Set)
.union(Set)
public final Set<A> filter(F<A,java.lang.Boolean> f)
true
when the given function is applied to them.f
- The predicate function to filter on.public final Set<A> delete(A a)
a
- an element to remove.public final F<A,F<Set<A>,Set<A>>> delete()
public final Set<A> intersect(Set<A> s)
s
- A set of elements to retain.public static <A> F<Set<A>,F<Set<A>,Set<A>>> intersect()
intersect(Set)
.intersect(Set)
public final Set<A> minus(Set<A> s)
s
- A set of elements to delete.public static <A> F<Set<A>,F<Set<A>,Set<A>>> minus()
minus(Set)
.minus(Set)
public final int size()
public final P3<Set<A>,Option<A>,Set<A>> split(A a)
a
- A value at which to split this set.public final boolean subsetOf(Set<A> s)
s
- A set which is a superset of this set if this method returns true.public static <A> Set<A> join(Ord<A> o, Set<Set<A>> s)
s
- A set of sets.o
- An order for the elements of the new set.public static <A> Set<A> iterableSet(Ord<A> o, java.lang.Iterable<A> as)
o
- An order for the elements of the new set.as
- An iterable of elements to add to a set.