Top Inners Constructors Methods
org.glassfish.pfl.basic.algorithm

public final Class Algorithms

extends Object
Class Inheritance
Imports
java.security.AccessController, .PrivilegedAction, java.util.ArrayList, .Arrays, .Collection, .HashMap, .List, .Map, org.glassfish.pfl.basic.contain.Pair, org.glassfish.pfl.basic.func.BinaryFunction, .UnaryFunction, .UnaryPredicate

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <A> UnaryPredicate<A>
and(final UnaryPredicate<A> arg1, final UnaryPredicate<A> arg2)
References Deprecated UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

public static List<E>
convertToList(Object arg)

Converts obj from an Array to a List, if obj is an array.

public static String
convertToString(Object
Object to convert.
arg
)

Convert argument to String, either by toString, ot Arrays.toString.

public static <T> T
public static <T> UnaryPredicate<T>
FALSE(Class<T> cls)
References Deprecated UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

public static <A> void
filter(final List<A> arg, final List<A> result, final UnaryPredicate<A> predicate)
References Deprecated UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

public static <A> List<A>
filter(List<A> arg, UnaryPredicate<A> predicate)
References Deprecated UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

public static <A> A
find(List<A> arg, UnaryPredicate<A> predicate)
References Deprecated UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

public static <
Type of elements of list.
S
,
Type of elements of result.
T
>
List<T>

Returns:

List<T> containing results of applying map to each element of list.
flatten
(final List<S>
List of elements of type S.
list
,
final UnaryFunction<S, List<T>>
function mapping S to List<T>.
map
)
References Deprecated UnaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

Flatten the results of applying map to list into a list of T.

public static <A, R> R
fold(List<A> list, R initial, BinaryFunction<R, A, R> func)
References Deprecated BinaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

public static <
The type of the list element.
T
>
T

Returns:

The first element of the list, if any.
getFirst
(Collection<T>
The list
list
,
Runnable
A runnable to call when the list is empty. Typically throws an exception.
handleEmptyList
)

Return the first element of the list, or invoke handleEmptyList if list is empty.

private static <T> PrivilegedAction<T>
public static <K, V> Map<K, V>
map(Pair<K, V>... pairs)

public static <A, R> void
map(final Collection<A> arg, final Collection<R> result, final UnaryFunction<A, R> func)
References Deprecated UnaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

public static <K, A, R> Map<K, R>
map(final Map<K, A> arg, final UnaryFunction<A, R> func)
References Deprecated UnaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

public static <A, R> List<R>
map(final List<A> arg, final UnaryFunction<A, R> func)
References Deprecated UnaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

public static <A, R> UnaryFunction<A, R>
mapToFunction(final Map<A, R> map)
References Deprecated UnaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

public static <A> UnaryPredicate<A>
not(final UnaryPredicate<A> arg1)
References Deprecated UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

public static <A> UnaryPredicate<A>
or(final UnaryPredicate<A> arg1, final UnaryPredicate<A> arg2)
References Deprecated UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

public static <S, T> Pair<S, T>
pair(S first, T second)

public static <T> UnaryPredicate<T>
TRUE(Class<T> cls)
References Deprecated UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Algorithmsback to summary
private Algorithms()

Method Detail

andback to summary
public static <A> UnaryPredicate<A> and(final UnaryPredicate<A> arg1, final UnaryPredicate<A> arg2)

References Deprecated

UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

convertToListback to summary
public static List<E> convertToList(Object arg)

Converts obj from an Array to a List, if obj is an array. Otherwise just returns a List containing obj.

Annotations
@SuppressWarnings:unchecked
convertToStringback to summary
public static String convertToString(Object arg)

Convert argument to String, either by toString, ot Arrays.toString.

Parameters
arg:Object

Object to convert.

doPrivilegedback to summary
public static <T> T doPrivileged(Algorithms.Action<T> func)
FALSEback to summary
public static <T> UnaryPredicate<T> FALSE(Class<T> cls)

References Deprecated

UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

filterback to summary
public static <A> void filter(final List<A> arg, final List<A> result, final UnaryPredicate<A> predicate)

References Deprecated

UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

filterback to summary
public static <A> List<A> filter(List<A> arg, UnaryPredicate<A> predicate)

References Deprecated

UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

findback to summary
public static <A> A find(List<A> arg, UnaryPredicate<A> predicate)

References Deprecated

UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

flattenback to summary
public static <S, T> List<T> flatten(final List<S> list, final UnaryFunction<S, List<T>> map)

References Deprecated

UnaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Flatten the results of applying map to list into a list of T.

Parameters
<S>
Type of elements of list.
<T>
Type of elements of result.
list:List<S>

List of elements of type S.

map:UnaryFunction<S, List<T>>

function mapping S to List<T>.

Returns:List<T>

List<T> containing results of applying map to each element of list.

foldback to summary
public static <A, R> R fold(List<A> list, R initial, BinaryFunction<R, A, R> func)

References Deprecated

BinaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

getFirstback to summary
public static <T> T getFirst(Collection<T> list, Runnable handleEmptyList)

Return the first element of the list, or invoke handleEmptyList if list is empty.

Parameters
<T>
The type of the list element.
list:Collection<T>

The list

handleEmptyList:Runnable

A runnable to call when the list is empty. Typically throws an exception.

Returns:T

The first element of the list, if any.

makePrivilegedActionback to summary
private static <T> PrivilegedAction<T> makePrivilegedAction(final Algorithms.Action<T> act)
mapback to summary
public static <K, V> Map<K, V> map(Pair<K, V>... pairs)
mapback to summary
public static <A, R> void map(final Collection<A> arg, final Collection<R> result, final UnaryFunction<A, R> func)

References Deprecated

UnaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

mapback to summary
public static <K, A, R> Map<K, R> map(final Map<K, A> arg, final UnaryFunction<A, R> func)

References Deprecated

UnaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

mapback to summary
public static <A, R> List<R> map(final List<A> arg, final UnaryFunction<A, R> func)

References Deprecated

UnaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

mapToFunctionback to summary
public static <A, R> UnaryFunction<A, R> mapToFunction(final Map<A, R> map)

References Deprecated

UnaryFunction is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

notback to summary
public static <A> UnaryPredicate<A> not(final UnaryPredicate<A> arg1)

References Deprecated

UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

orback to summary
public static <A> UnaryPredicate<A> or(final UnaryPredicate<A> arg1, final UnaryPredicate<A> arg2)

References Deprecated

UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

pairback to summary
public static <S, T> Pair<S, T> pair(S first, T second)
TRUEback to summary
public static <T> UnaryPredicate<T> TRUE(Class<T> cls)

References Deprecated

UnaryPredicate is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

org.glassfish.pfl.basic.algorithm back to summary

public Interface Algorithms.Action<T>


Method Summary

Modifier and TypeMethod and Description
public T
run()

Method Detail

runback to summary
public T run() throws Exception