Functions: FnArray

1. Overview

FnArray 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 Arrays:

FnArrayOf

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

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

The examples below show how these functions can be used:

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

FnArrayOfArrayOf

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

/* The code below flattens the target Array of Array so, the result of the operation will be the array ["first", "second", "third"] */
Op.on(new String[][] {Op.onArrayFor("first", "second").get(), Op.onArrayFor("third").get()})
                .castToArrayOf(Types.ARRAY_OF_STRING).exec(
                FnArray.ofArrayOf(Types.STRING).flattenArrays()).get();
Function nameTypeParamsDescription
flattenArraysFunction<T[][],T[]>

FnArrayOfListOf

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

/* The code below flattens the target Array of List so, the result of the operation will be the array ["first", "second", "third"] */
Op.on(new List[] {Op.onListFor("first", "second").get(), Op.onListFor("third").get()})
    .castToArrayOf(Types.LIST_OF_STRING).exec(
        FnArray.ofListOf(Types.STRING).flattenLists()).get();
Function nameTypeParamsDescription
flattenListsFunction<List<T>[],T[]>

FnArrayOfSetOf

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

/* The code below flattens the target Array of Set so, the result of the operation will be the array ["first", "second", "third"] */
Op.on(new Set[] {Op.onSetFor("first", "second").get(), Op.onSetFor("third").get()})
    .castToArrayOf(Types.SET_OF_STRING).exec(
        FnArray.ofSetOf(Types.STRING).flattenSets()).get();
Function nameTypeParamsDescription
flattenSetsFunction<Set<T>[],T[]>