org.rubato.logeo
Class Lists

java.lang.Object
  extended by org.rubato.logeo.Lists

public final class Lists
extends java.lang.Object

This class implements various operations on denotators of type list. Arguments to these methods must not be null.

Author:
Gérard Milmeister

Method Summary
static ListDenotator appendElement(ListDenotator d, Denotator element)
          Appends an element denotator to a list denotator.
static void appendElementTo(ListDenotator d, Denotator element)
          Appends a denotator to a list denotator.
static void appendTo(ListDenotator d1, ListDenotator d2)
          Appends the elements of d2 to d1.
static void apply(Function f, ListDenotator d)
          Applies the function f to every factor of the argument denotator.
static ListDenotator concat(ListDenotator... denoList)
          Returns a list denotator that is the concatenation of the argument list denotators.
static ListDenotator concat(ListDenotator d1, ListDenotator d2)
          Returns a list denotator that is the concatenation of d1 and d2.
static Denotator map(Function f, ListDenotator d)
          Returns a denotator, with f applied to the elements of d.
static ListDenotator prependElement(ListDenotator d, Denotator element)
          Prepends a denotator to a list denotator.
static void prependElementTo(ListDenotator d, Denotator element)
          Prepends a denotator to a list denotator.
static void prependTo(ListDenotator d1, ListDenotator d2)
          Prepend the elements of d2 to d1.
static Denotator reduce(Function f, ListDenotator d)
          Reduces the argument list denotator using the function f.
static ListDenotator removeDuplicates(ListDenotator d)
          Removes duplicates from the list denotator.
static ListDenotator select(Predicate p, ListDenotator d)
          Returns a denotator, where only the elements from the argument denotator are contained that satisfy predicate p.
static ListDenotator sort(ListDenotator d)
          Sorts the list denotator according to canonical order.
static ListDenotator sort(ListDenotator d, java.util.Comparator<Denotator> c)
          Sorts the list denotator according to order induced by the comparator c, which can also be a Predicate.
static ListDenotator zip(Function f, ListDenotator d1, ListDenotator d2)
          Zips the function on the two argument lists.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

concat

public static ListDenotator concat(ListDenotator d1,
                                   ListDenotator d2)
                            throws RubatoException
Returns a list denotator that is the concatenation of d1 and d2.

Throws:
RubatoException - if d1 or d2 is not of the required form

concat

public static ListDenotator concat(ListDenotator... denoList)
                            throws RubatoException
Returns a list denotator that is the concatenation of the argument list denotators.

Throws:
RubatoException - if the denotators do not have the required form

appendTo

public static void appendTo(ListDenotator d1,
                            ListDenotator d2)
                     throws RubatoException
Appends the elements of d2 to d1. This operation is destructive on the first argument.

Throws:
RubatoException - if d1 or d2 is not of the required form, or if they do not have the same address

appendElement

public static ListDenotator appendElement(ListDenotator d,
                                          Denotator element)
                                   throws RubatoException
Appends an element denotator to a list denotator.

Throws:
RubatoException

appendElementTo

public static void appendElementTo(ListDenotator d,
                                   Denotator element)
                            throws RubatoException
Appends a denotator to a list denotator. This operation is destructive on the first argument.

Throws:
RubatoException

prependTo

public static void prependTo(ListDenotator d1,
                             ListDenotator d2)
                      throws RubatoException
Prepend the elements of d2 to d1. This operation is destructive on the first argument.

Throws:
RubatoException - if d1 or d2 is not of the required form

prependElement

public static ListDenotator prependElement(ListDenotator d,
                                           Denotator element)
                                    throws RubatoException
Prepends a denotator to a list denotator.

Throws:
RubatoException

prependElementTo

public static void prependElementTo(ListDenotator d,
                                    Denotator element)
                             throws RubatoException
Prepends a denotator to a list denotator. This operation is destructive on the first argument.

Throws:
RubatoException

map

public static Denotator map(Function f,
                            ListDenotator d)
                     throws RubatoException
Returns a denotator, with f applied to the elements of d.

Parameters:
f - the function to apply to the arguments, must have arity == 1
Throws:
RubatoException - if d is not of the required form or f has arity != 1

apply

public static void apply(Function f,
                         ListDenotator d)
                  throws RubatoException
Applies the function f to every factor of the argument denotator.

Parameters:
f - the function to apply to the argument factors, must have arity 1
Throws:
RubatoException - if f has arity != 1

select

public static ListDenotator select(Predicate p,
                                   ListDenotator d)
                            throws RubatoException
Returns a denotator, where only the elements from the argument denotator are contained that satisfy predicate p.

Parameters:
p - the predicate that the elements must satisfy, must have arity 1
Throws:
RubatoException - if d has not the required form or p has arity != 1

zip

public static ListDenotator zip(Function f,
                                ListDenotator d1,
                                ListDenotator d2)
                         throws RubatoException
Zips the function on the two argument lists. If d1 is a list denotator [d1_1,...,d1_m] and d2 is a list denotator [d2_1,...,d2_n], then zip(f,d1,d2) returns a list denotator [f(d1_1, d2_1),...,f(d1_k,d2_k)], where k = min(n,m).

Parameters:
f - a function of arity 2, must have a first argument of the same form as a list element of d1 and a second argument of the same form as a list element of d2
Throws:
RubatoException - if d1 or d2 is not of the required form or f has not the required type

reduce

public static Denotator reduce(Function f,
                               ListDenotator d)
                        throws RubatoException
Reduces the argument list denotator using the function f. If d is a list denotator [d1_1,...,d1_m], then reduce(f, d) returns f(...f(f(d_1, d_2),d_3)...d_m)

Parameters:
f - a function of arity 2, must have both arguments of the same form as the element form of the list denotator.
Throws:
RubatoException - if d is not of the required form or f has arity != 2

sort

public static ListDenotator sort(ListDenotator d)
Sorts the list denotator according to canonical order.


sort

public static ListDenotator sort(ListDenotator d,
                                 java.util.Comparator<Denotator> c)
Sorts the list denotator according to order induced by the comparator c, which can also be a Predicate.


removeDuplicates

public static ListDenotator removeDuplicates(ListDenotator d)
Removes duplicates from the list denotator. Requires that the denotator has been sorted before according to canonical order.