Beispiel #1
0
 /// <summary>
 /// Returns a new query operation that represents the combination of this query sequence with another
 /// query sequence.  The two sequences are combined element-by-element using a selector function.
 /// The resulting sequence has a length equal to the smaller of the two sequences.
 ///
 /// For example:
 ///   sequenceA = (A, B, C, D)
 ///   sequenceB = (E, F, G, H)
 ///   sequenceA.Query().Zip(sequenceB.Query(), (a, b) => a + b)
 /// Would result in:
 ///   (AE, BF, CG, DH)
 /// </summary>
 public QueryWrapper <NewType, ZipOp <NewType, QueryType, OtherType, QueryOp, OtherOp> > Zip <NewType, OtherType, OtherOp>(QueryWrapper <OtherType, OtherOp> sourceB, Func <QueryType, OtherType, NewType> resultSelector)
     where OtherOp : IQueryOp <OtherType>
 {
     return(new QueryWrapper <NewType, ZipOp <NewType, QueryType, OtherType, QueryOp, OtherOp> >(new ZipOp <NewType, QueryType, OtherType, QueryOp, OtherOp>(_op, sourceB._op, resultSelector)));
 }
 public static T Max <QueryType, QueryOp, T>(this QueryWrapper <QueryType, QueryOp> wrapper, Func <QueryType, T> selector)
     where T : IComparable <T>
     where QueryOp : IQueryOp <QueryType>
 {
     return(wrapper.Select(selector).Fold((a, b) => a.CompareTo(b) > 0 ? a : b));
 }
 public static QueryType Max <QueryType, QueryOp>(this QueryWrapper <QueryType, QueryOp> wrapper)
     where QueryType : IComparable <QueryType>
     where QueryOp : IQueryOp <QueryType>
 {
     return(wrapper.Fold((a, b) => a.CompareTo(b) > 0 ? a : b));
 }
 public static QueryWrapper <float, SelectOp <QueryType, float, QueryOp> > ToFloats <QueryType, QueryOp>(this QueryWrapper <QueryType, QueryOp> wrapper)
     where QueryOp : IQueryOp <QueryType>
     where QueryType : IConvertible
 {
     return(wrapper.Select(FormatHelper <QueryType> .toFloat));
 }
 public static QueryWrapper <long, SelectOp <QueryType, long, QueryOp> > ToLongs <QueryType, QueryOp>(this QueryWrapper <QueryType, QueryOp> wrapper)
     where QueryOp : IQueryOp <QueryType>
     where QueryType : IConvertible
 {
     return(wrapper.Select(FormatHelper <QueryType> .toLong));
 }
 public static QueryWrapper <byte, SelectOp <QueryType, byte, QueryOp> > ToBytes <QueryType, QueryOp>(this QueryWrapper <QueryType, QueryOp> wrapper)
     where QueryOp : IQueryOp <QueryType>
     where QueryType : IConvertible
 {
     return(wrapper.Select(FormatHelper <QueryType> .toByte));
 }