View Javadoc

    1   package sharin.unlinq;
    2
    3   import java.util.Comparator;
    4   import java.util.List;
    5   import java.util.Map;
    6
    7   public interface Enumerable<T> extends Iterable<T> {
    8
    9       public T aggregate(Func2<T, T, T> func);
    10
    11      public <A> A aggregate(A seed, Func2<A, T, A> func);
    12
    13      public <A, R> R aggregate(A seed, Func2<A, T, A> func,
    14              Func<A, R> resultSelector);
    15
    16      public Boolean all(Func<T, Boolean> predicate);
    17
    18      public Boolean any();
    19
    20      public Boolean any(Func<T, Boolean> predicate);
    21
    22      public double average();
    23
    24      public double averageLong();
    25
    26      public float averageFloat();
    27
    28      public double averageDouble();
    29
    30      public double average(Func<T, Integer> selector);
    31
    32      public double averageLong(Func<T, Long> selector);
    33
    34      public float averageFloat(Func<T, Float> selector);
    35
    36      public double averageDouble(Func<T, Double> selector);
    37
    38      public <R> Enumerable<R> cast(Class<R> resultClass);
    39
    40      public Enumerable<T> concat(Enumerable<T> second);
    41
    42      public boolean contains(Object o);
    43
    44      public int count();
    45
    46      public int count(Func<T, Boolean> predicate);
    47
    48      public Enumerable<T> defaultIfEmpty();
    49
    50      public Enumerable<T> defaultIfEmpty(T defaultValue);
    51
    52      public Enumerable<T> distinct();
    53
    54      public T elementAt(int index);
    55
    56      public T elementAtOrDefault(int index);
    57
    58      public T elementAtOrDefault(int index, T defaultValue);
    59
    60      public Enumerable<T> except(Enumerable<T> second);
    61
    62      public T first();
    63
    64      public T first(Func<T, Boolean> predicate);
    65
    66      public T firstOrDefault();
    67
    68      public T firstOrDefault(T defaultValue);
    69
    70      public T firstOrDefault(Func<T, Boolean> predicate);
    71
    72      public T firstOrDefault(Func<T, Boolean> predicate, T defaultValue);
    73
    74      public <K> Enumerable<Grouping<K, T>> groupBy(Func<T, K> keySelector);
    75
    76      public <K, R> Enumerable<R> groupBy(Func<T, K> keySelector,
    77              Func2<K, Enumerable<T>, R> resultSelector);
    78
    79      public <K, E> Enumerable<Grouping<K, E>> groupBy(Func<T, K> keySelector,
    80              Func<T, E> elementSelector);
    81
    82      public <K, E, R> Enumerable<R> groupBy(Func<T, K> keySelector,
    83              Func<T, E> elementSelector,
    84              Func2<K, Enumerable<E>, R> resultSelector);
    85
    86      public <I, K, R> Enumerable<R> groupJoin(Enumerable<I> inner,
    87              Func<T, K> outerKeySelector, Func<I, K> innerKeySelector,
    88              Func2<T, Enumerable<I>, R> resultSelector);
    89
    90      public Enumerable<T> intersect(Enumerable<T> second);
    91
    92      public <I, K, R> Enumerable<R> join(Enumerable<I> inner,
    93              Func<T, K> outerKeySelector, Func<I, K> innerKeySelector,
    94              Func2<T, I, R> resultSelector);
    95
    96      public T last();
    97
    98      public T last(Func<T, Boolean> predicate);
    99
    100     public T lastOrDefault();
    101
    102     public T lastOrDefault(T defaultValue);
    103
    104     public T lastOrDefault(Func<T, Boolean> predicate);
    105
    106     public T lastOrDefault(Func<T, Boolean> predicate, T defaultValue);
    107
    108     public long longCount();
    109
    110     public long longCount(Func<T, Boolean> predicate);
    111
    112     public T max();
    113
    114     public <R extends Comparable<R>> R max(Func<T, R> selector);
    115
    116     public T min();
    117
    118     public <R extends Comparable<R>> R min(Func<T, R> selector);
    119
    120     public <R> Enumerable<R> ofType(Class<R> resultClass);
    121
    122     public <K> OrderedEnumerable<T> orderBy(Func<T, K> keySelector);
    123
    124     public <K> OrderedEnumerable<T> orderBy(Func<T, K> keySelector,
    125             Comparator<K> comparator);
    126
    127     public <K> OrderedEnumerable<T> orderByDescending(Func<T, K> keySelector);
    128
    129     public <K> OrderedEnumerable<T> orderByDescending(Func<T, K> keySelector,
    130             Comparator<K> comparator);
    131
    132     public Enumerable<T> reverse();
    133
    134     public <R> Enumerable<R> select(Func2<T, Integer, R> selector);
    135
    136     public <R> Enumerable<R> select(Func<T, R> selector);
    137
    138     public <R> Enumerable<R> selectMany(Func<T, Enumerable<R>> selector);
    139
    140     public <R> Enumerable<R> selectMany(
    141             Func2<T, Integer, Enumerable<R>> selector);
    142
    143     public <C, R> Enumerable<R> selectMany(
    144             Func<T, Enumerable<C>> collectionSelector,
    145             Func2<T, C, R> resultSelector);
    146
    147     public <C, R> Enumerable<R> selectMany(
    148             Func2<T, Integer, Enumerable<C>> collectionSelector,
    149             Func2<T, C, R> resultSelector);
    150
    151     public Boolean sequenceEqual(Enumerable<T> second);
    152
    153     public T single();
    154
    155     public T single(Func<T, Boolean> predicate);
    156
    157     public T singleOrDefault();
    158
    159     public T singleOrDefault(T defaultValue);
    160
    161     public T singleOrDefault(Func<T, Boolean> predicate);
    162
    163     public T singleOrDefault(Func<T, Boolean> predicate, T defaultValue);
    164
    165     public Enumerable<T> skip(int count);
    166
    167     public Enumerable<T> skipWhile(Func<T, Boolean> predicate);
    168
    169     public Enumerable<T> skipWhile(Func2<T, Integer, Boolean> predicate);
    170
    171     public int sum();
    172
    173     public long sumLong();
    174
    175     public float sumFloat();
    176
    177     public double sumDouble();
    178
    179     public int sum(Func<T, Integer> selector);
    180
    181     public long sumLong(Func<T, Long> selector);
    182
    183     public float sumFloat(Func<T, Float> selector);
    184
    185     public double sumDouble(Func<T, Double> selector);
    186
    187     public Enumerable<T> take(int count);
    188
    189     public Enumerable<T> takeWhile(Func<T, Boolean> predicate);
    190
    191     public Enumerable<T> takeWhile(Func2<T, Integer, Boolean> predicate);
    192
    193     public Object[] toArray();
    194
    195     public <R> R[] toArray(Class<R> resultClass);
    196
    197     public <K> Map<K, T> toMap(Func<T, K> keySelector);
    198
    199     public <K, E> Map<K, E> toMap(Func<T, K> keySelector,
    200             Func<T, E> elementSelector);
    201
    202     public <K> Dictionary<K, T> toDictionary(Func<T, K> keySelector);
    203
    204     public <K, E> Dictionary<K, E> toDictionary(Func<T, K> keySelector,
    205             Func<T, E> elementSelector);
    206
    207     public List<T> toList();
    208
    209     public EnumerableList<T> toEnumerableList();
    210
    211     public <K> Map<K, List<T>> toListMap(Func<T, K> keySelector);
    212
    213     public <K, E> Map<K, List<E>> toListMap(Func<T, K> keySelector,
    214             Func<T, E> elementSelector);
    215
    216     public <K> Lookup<K, T> toLookup(Func<T, K> keySelector);
    217
    218     public <K, E> Lookup<K, E> toLookup(Func<T, K> keySelector,
    219             Func<T, E> elementSelector);
    220
    221     public Enumerable<T> union(Enumerable<T> second);
    222
    223     public Enumerable<T> where(Func<T, Boolean> predicate);
    224
    225     public Enumerable<T> where(Func2<T, Integer, Boolean> predicate);
    226 }