From: <bo...@us...> - 2010-09-24 09:47:34
|
Revision: 482 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=482&view=rev Author: bodewig Date: 2010-09-24 09:47:28 +0000 (Fri, 24 Sep 2010) Log Message: ----------- docs Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java trunk/xmlunit/src/main/net-core/util/Linqy.cs Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java 2010-09-17 11:50:31 UTC (rev 481) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java 2010-09-24 09:47:28 UTC (rev 482) @@ -18,6 +18,9 @@ import java.util.List; import java.util.NoSuchElementException; +/** + * A couple of (functional) sequence processing constructs. + */ public final class Linqy { /** * Turns the iterable into a list. @@ -30,6 +33,9 @@ return a; } + /** + * Turns an iterable into its type-safe cousin. + */ public static <E> Iterable<E> cast(final Iterable i) { return map(i, new Mapper<Object, E>() { public E map(Object o) { @@ -38,6 +44,9 @@ }); } + /** + * An iterable containing a single element. + */ public static <E> Iterable<E> singleton(final E single) { return new Iterable<E>() { public Iterator<E> iterator() { @@ -46,6 +55,10 @@ }; } + /** + * Create a new iterable by applying a mapper function to each + * element of a given sequence. + */ public static <F, T> Iterable<T> map(final Iterable<F> from, final Mapper<? super F, T> mapper) { return new Iterable<T>() { @@ -55,10 +68,17 @@ }; } + /** + * A function mapping from one type to another. + */ public interface Mapper<F, T> { T map(F from); } + /** + * Exclude all elements from an iterable that don't match a given + * predicate. + */ public static <T> Iterable<T> filter(final Iterable<T> sequence, final Predicate<? super T> filter) { return new Iterable<T>() { @@ -68,10 +88,16 @@ }; } + /** + * A function that tests an object for a property. + */ public interface Predicate<T> { boolean matches(T toTest); } + /** + * Count the number of elements in a sequence. + */ public static int count(Iterable seq) { int c = 0; Iterator it = seq.iterator(); Modified: trunk/xmlunit/src/main/net-core/util/Linqy.cs =================================================================== --- trunk/xmlunit/src/main/net-core/util/Linqy.cs 2010-09-17 11:50:31 UTC (rev 481) +++ trunk/xmlunit/src/main/net-core/util/Linqy.cs 2010-09-24 09:47:28 UTC (rev 482) @@ -17,21 +17,30 @@ namespace net.sf.xmlunit.util { /// <summary> - /// Conversion methods. + /// A couple of (functional) sequence processing constructs. /// </summary> public sealed class Linqy { + + /// <summary> + /// Turns an enumerable into its type-safe cousin. + /// </summary> public static IEnumerable<T> Cast<T>(IEnumerable i) { foreach (T t in i) { yield return t; } } + /// <summary> + /// An enumerable containing a single element. + /// </summary> public static IEnumerable<T> Singleton<T>(T t) { yield return t; } - public delegate T Mapper<F, T>(F from); - + /// <summary> + /// Create a new enumerable by applying a mapper function to + /// each element of a given sequence. + /// </summary> public static IEnumerable<T> Map<F, T>(IEnumerable<F> from, Mapper<F, T> mapper) { foreach (F f in from) { @@ -39,8 +48,15 @@ } } - public delegate bool Predicate<T>(T toTest); + /// <summary> + /// A function mapping from one type to another. + /// </summary> + public delegate T Mapper<F, T>(F from); + /// <summary> + /// Exclude all elements from an enumerable that don't match a + /// given predicate. + /// </summary> public static IEnumerable<T> Filter<T>(IEnumerable<T> sequence, Predicate<T> filter) { foreach (T t in sequence) { @@ -50,6 +66,14 @@ } } + /// <summary> + /// A function that tests an object for a property. + /// </summary> + public delegate bool Predicate<T>(T toTest); + + /// <summary> + /// Count the number of elements in a sequence. + /// </summary> public static int Count(IEnumerable e) { int c = 0; foreach (object o in e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |