org.apache.ode.utils.stl

## Class CollectionsX

- java.lang.Object
- - org.apache.ode.utils.stl.CollectionsX

-     public class CollectionsX
      extends java.lang.Object

  Useful extensions to the java.util.Collections class.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static UnaryFunction<java.util.Map.Entry,java.lang.Object>` | `ufnMapEntry_getKey`
    `static UnaryFunction<java.util.Map.Entry,java.lang.Object>` | `ufnMapEntry_getValue`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CollectionsX()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> void` | `apply(java.util.Collection<T> coll, UnaryFunction<T,?> f)`
    `static <T> void` | `apply(java.util.Collection<T> coll, UnaryFunctionEx<T,?> f)`
    `static <T> void` | `apply(java.util.Iterator<T> i, UnaryFunction<T,?> f)`
    `static <T> void` | `apply(java.util.Iterator<T> i, UnaryFunctionEx<T,?> f)`
    `static <C extends java.util.Collection<T>,S,T extends S> C` | `filter(C dest, java.util.Collection<S> src, java.lang.Class<T> t)`
    `static <C extends java.util.Collection<T>,T,S extends T> C` | `filter(C dest, java.util.Collection<S> source, MemberOfFunction<S> function)`
    `static <C extends java.util.Collection<T>,S,T extends S> C` | `filter(C newList, java.util.Iterator<S> iterator, java.lang.Class<T> t)`
    `static <C extends java.util.Collection<T>,T,S extends T> C` | `filter(C dest, java.util.Iterator<S> source, MemberOfFunction<S> function)`
    `static <T> java.util.Collection<T>` | `filter(java.util.Collection src, java.lang.Class<T> aClass)` Filter a collection by member class.
    `static <T> T` | `find_if(java.util.Collection<T> coll, MemberOfFunction<? super T> f)` Find an element in a colletion satisfying a condition.
    `static <T> T` | `find_if(java.util.Iterator<T> i, MemberOfFunction<? super T> f)` Find an element in a collection satisfying a condition.
    `static <T> java.util.Collection<T>` | `insert(java.util.Collection<T> coll, java.util.Collection<? extends T> src)`
    `static <T> java.util.Collection<T>` | `insert(java.util.Collection<T> coll, java.util.Enumeration<? extends T> e)`
    `static <T> java.util.Collection<T>` | `insert(java.util.Collection<T> coll, java.util.Iterator<? extends T> i)`
    `static <T> java.util.Collection<T>` | `remove_if(java.util.Collection<T> coll, MemberOfFunction<T> f)` Remove elements from collection based on the results of specified unary function.
    `static <C extends java.util.Collection<T>,T,V extends T,E> C` | `transform(C dest, java.util.Collection<E> src, UnaryFunction<E,V> f)` Transform a collection with a unary function.
    `static <C extends java.util.Collection<T>,T,V extends T,E> C` | `transform(C dest, java.util.Enumeration<E> i, UnaryFunction<E,V> f)`
    `static <C extends java.util.Collection<T>,T,V extends T,E> C` | `transformEx(C dest, java.util.Collection<E> src, UnaryFunctionEx<E,V> f)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ufnMapEntry_getKey

          public static UnaryFunction<java.util.Map.Entry,java.lang.Object> ufnMapEntry_getKey

    - #### ufnMapEntry_getValue

          public static UnaryFunction<java.util.Map.Entry,java.lang.Object> ufnMapEntry_getValue

  - ### Constructor Detail

    - #### CollectionsX

          public CollectionsX()

  - ### Method Detail

    - #### apply

          public static <T> void apply(java.util.Collection<T> coll,
                       UnaryFunction<T,?> f)

    - #### apply

          public static <T> void apply(java.util.Iterator<T> i,
                       UnaryFunction<T,?> f)

    - #### apply

          public static <T> void apply(java.util.Collection<T> coll,
                       UnaryFunctionEx<T,?> f)
                            throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### apply

          public static <T> void apply(java.util.Iterator<T> i,
                       UnaryFunctionEx<T,?> f)
                            throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### find_if

          public static <T> T find_if(java.util.Collection<T> coll,
                      MemberOfFunction<? super T> f)

      Find an element in a colletion satisfying a condition. The condition is given in the form of a unary function which returns a non-`false` value when the condition is satisfied. The first object in the collection matching the condition is returned.
      Parameters:
        `coll` - the collection to search through
        `f` - the test to apply to the collection elements
      Returns:
        the first object in the collection (coll) which, satisfies the condition (f)

    - #### find_if

          public static <T> T find_if(java.util.Iterator<T> i,
                      MemberOfFunction<? super T> f)

      Find an element in a collection satisfying a condition.
      Parameters:
        `i` - the iterator to iterate with
        `f` - the test to apply to the elements
      Returns:
        the first object enumerated by the iterator (i) which satisfies the condition (f)
      See Also:
        `find_if(java.util.Collection, org.apache.ode.utils.stl.MemberOfFunction)`

    - #### insert

          public static <T> java.util.Collection<T> insert(java.util.Collection<T> coll,
                                           java.util.Enumeration<? extends T> e)

    - #### insert

          public static <T> java.util.Collection<T> insert(java.util.Collection<T> coll,
                                           java.util.Iterator<? extends T> i)

    - #### insert

          public static <T> java.util.Collection<T> insert(java.util.Collection<T> coll,
                                           java.util.Collection<? extends T> src)

    - #### remove_if

          public static <T> java.util.Collection<T> remove_if(java.util.Collection<T> coll,
                                              MemberOfFunction<T> f)

      Remove elements from collection based on the results of specified unary function. An element will be deleted if `f.isMember(element)` returns `true`. So: coll' = { x : x el-of coll AND f(x) == false }
      Parameters:
        `coll` - the collection from which to remove elements
        `f` - the function to apply
      Returns:
        coll, for convenience

    - #### transform

          public static <C extends java.util.Collection<T>,T,V extends T,E> C transform(C dest,
                                                                        java.util.Collection<E> src,
                                                                        UnaryFunction<E,V> f)

      Transform a collection with a unary function. Roughly speaking dest = { f(a) : a el-of src }
      Parameters:
        `dest` - the empty (mutable) collection to transform into
        `src` - the collection to transform from
        `f` - the unary function to apply
      Returns:
        dest, for convenience

    - #### transformEx

          public static <C extends java.util.Collection<T>,T,V extends T,E> C transformEx(C dest,
                                                                          java.util.Collection<E> src,
                                                                          UnaryFunctionEx<E,V> f)
                                                            throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### transform

          public static <C extends java.util.Collection<T>,T,V extends T,E> C transform(C dest,
                                                                        java.util.Enumeration<E> i,
                                                                        UnaryFunction<E,V> f)

    - #### filter

          public static <C extends java.util.Collection<T>,T,S extends T> C filter(C dest,
                                                                   java.util.Collection<S> source,
                                                                   MemberOfFunction<S> function)

    - #### filter

          public static <C extends java.util.Collection<T>,T,S extends T> C filter(C dest,
                                                                   java.util.Iterator<S> source,
                                                                   MemberOfFunction<S> function)

    - #### filter

          public static <C extends java.util.Collection<T>,S,T extends S> C filter(C dest,
                                                                   java.util.Collection<S> src,
                                                                   java.lang.Class<T> t)

    - #### filter

          public static <C extends java.util.Collection<T>,S,T extends S> C filter(C newList,
                                                                   java.util.Iterator<S> iterator,
                                                                   java.lang.Class<T> t)

    - #### filter

          public static <T> java.util.Collection<T> filter(java.util.Collection src,
                                           java.lang.Class<T> aClass)

      Filter a collection by member class.
      Parameters:
        `src` - source collection
        `aClass` - requested class
      Returns:
        collection consisting of the members of the input that are assignable to the given class