Functions: FnSet

1. Overview

FnSet is a parameterizable function hub class and, before giving you access to the real functions, you will have to specify the type parameter, which will give you access to the functions containing the operations on Sets:

FnSetOf

The functions in FnSetOf are applied on Sets. FnSetOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnSet.ofBigDecimal(), FnSet.ofLong(), FnSet.of(final Type<T> type), ...).

FnSet.of(final Type<T> type) is the most generic method that gives you access to FnSetOf though there are some shortcuts for common classes: FnSet.ofBigDecimal(), FnSet.ofInteger(), FnSet.ofDate(), FnSet.ofCharacter(), ...

The examples below show how these functions can be used:

/* This piece of code converts the Strings into Calendar and sorts them */        
Op.onSetFor("2000/11/10", "2010/10/10", "2000/01/10")
	.forEach().exec(FnString.toCalendar("yyyy/MM/dd")).endFor()
	.exec(FnSet.ofCalendar().sort()).get();
	
/* This piece of code creates the map {first = [23], second = [2.3], third = [-23.456]} */        
Op.onSetFor(BigDecimal.valueOf(23), BigDecimal.valueOf(2.3), BigDecimal.valueOf(-23.456))
	.exec(FnSet.ofBigDecimal().zipAndGroupKeys("first", "second", "third")).get();
	
/* This piece of code creates the map {ff0000 = red, 00ff00 = green, 0000ff = blue} */	
Op.onSetFor("ff0000", "red", "00ff00", "green", "0000ff", "blue")
	.exec(FnSet.ofString().couple()).get();
Function nameTypeParamsDescription
addFunction<Set<T>,Set<T>>T... newElements
addAllFunction<Set<T>,Set<T>>Collection<T> collection
allFunction<Set<T>,Boolean>IFunction<? super T,Boolean> eval
anyFunction<Set<T>,Boolean>IFunction<? super T,Boolean> eval
containsFunction<Set<T>,Boolean>T object
containsAllFunction<Set<T>,Boolean>T... objects
containsAnyFunction<Set<T>,Boolean>T... objects
containsNoneFunction<Set<T>,Boolean>T... objects
countFunction<Set<T>,Integer>
coupleFunction<Set<T>,Map<T,T>>
coupleAndGroupFunction<Set<T>,Map<T,Set<T>>>
insertFunction<Set<T>,Set<T>>int position
T... newElements
notContainsFunction<Set<T>,Boolean>T object
removeAllEqualFunction<Set<T>,Set<T>>T... values
removeAllFalseFunction<Set<T>,Set<T>>IFunction<? super T,Boolean> eval
removeAllIndexesFunction<Set<T>,Set<T>>int... indexes
removeAllIndexesNotFunction<Set<T>,Set<T>>int... indexes
removeAllNotNullAndFalseFunction<Set<T>,Set<T>>IFunction<? super T,Boolean> eval
removeAllNotNullAndTrueFunction<Set<T>,Set<T>>IFunction<? super T,Boolean> eval
removeAllNullFunction<Set<T>,Set<T>>
removeAllNullOrFalseFunction<Set<T>,Set<T>>IFunction<? super T,Boolean> eval
removeAllNullOrTrueFunction<Set<T>,Set<T>>IFunction<? super T,Boolean> eval
removeAllTrueFunction<Set<T>,Set<T>>IFunction<? super T,Boolean> eval
reverseFunction<Set<T>,Set<T>>
sortFunction<Set<T>,Set<T>>
sortFunction<Set<T>,Set<T>>Comparator<? super T> comparator
sortByFunction<Set<T>,Set<T>>IFunction<? super T, ?> by
toArrayFunction<Set<T>,T[]>
toGroupMapFunction<Set<T>,Map<K,Set<V>>>IFunction<? super T,Map.Entry<K,V>> mapBuilder
toGroupMapFunction<Set<T>,Map<K,Set<V>>>IFunction<? super T,K> keyFunction
IFunction<? super T,V> valueFunction
toListFunction<Set<T>,List<T>>
toMapFunction<Set<T>,Map<K,V>>IFunction<? super T,Map.Entry<K,V>> mapBuilder
toMapFunction<Set<T>,Map<K,V>>IFunction<? super T,K> keyFunction
IFunction<? super T,V> valueFunction
zipAndGroupKeysFunction<Set<T>,Map<K,Set<T>>>K... keys
zipAndGroupKeysByFunction<Set<T>,Map<K,Set<T>>>IFunction<? super T, K> eval
zipAndGroupKeysFromFunction<Set<T>,Map<K,Set<T>>>Collection<K> keys
zipAndGroupKeysFromFunction<Set<T>,Map<K,Set<T>>>K[] keys
zipAndGroupValuesFunction<Set<T>,Map<T,Set<V>>>V... values
zipAndGroupValuesByFunction<Set<T>,Map<T,Set<V>>>IFunction<? super T, V> eval
zipAndGroupValuesFromFunction<Set<T>,Map<T,Set<V>>>Collection<V> values
zipAndGroupValuesFromFunction<Set<T>,Map<T,Set<V>>>V[] values
zipKeysFunction<Set<T>,Map<K,T>>K... keys
zipKeysByFunction<Set<T>,Map<K,T>>IFunction<? super T, K> eval
zipKeysFromFunction<Set<T>,Map<K,T>>Collection<K> keys
zipKeysFromFunction<Set<T>,Map<K,T>>K[] keys
zipValuesFunction<Set<T>,Map<T,V>>V... values
zipValuesByFunction<Set<T>,Map<T,V>>IFunction<? super T, V> eval
zipValuesFromFunction<Set<T>,Map<T,V>>Collection<V> values
zipValuesFromFunction<Set<T>,Map<T,V>>V[] values

FnSetOfArrayOf

The functions in FnSetOfArrayOf are applied on Sets of Arrays of any type. FnSetOfArrayOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnSet.ofArrayOf(Types.INTEGER), FnSet.ofArrayOf(Types.LONG)). The example below shows how it can be used:

/* The code below flattens the target Set of Arrays so, the result of the operation, is the set ["first", "second", "third"] */
Op.onSetFor(Op.onArrayFor("first", "second").get(), Op.onArrayFor("third").get())
            .exec(FnSet.ofArrayOf(Types.STRING).flattenArrays()).get();
Function nameTypeParamsDescription
flattenArraysFunction<Set<T[]>,Set<T>>

FnSetOfListOf

The functions in FnSetOfListOf are applied on Sets of Lists of any type. FnSetOfListOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnSet.ofListOf(Types.INTEGER), FnSet.ofListOf(Types.LONG)). The example below shows how it can be used:

/* Suppose we have a Set<List<String>>, the piece of code below would return the flattened lists as a single set: ["first", "second", "third"] */
Op.onSetFor(Op.onListFor("first", "second").get(), Op.onListFor("third").get())
              .exec(FnSet.ofListOf(Types.STRING).flattenLists()).get();
Function nameTypeParamsDescription
flattenListsFunction<Set<List<T>>,Set<T>>

FnSetOfSetOf

The functions in FnSetOfSetOf are applied on Sets of Sets of any type. FnSetOfSetOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnSet.ofSetOf(Types.INTEGER), FnSet.ofSetOf(Types.LONG)). The example below shows how it can be used:

/* Suppose we have a Set<Set<String>>, the piece of code below would return the flattened sets as a single one: ["first", "second", "third"] */
Op.onSetFor(Op.onSetFor("first", "second").get(), Op.onSetFor("third").get())
              .exec(FnSet.ofSetOf(Types.STRING).flattenSets()).get()
Function nameTypeParamsDescription
flattenSetsFunction<Set<Set<T>>,Set<T>>