|
@@ -1,3 +1,6 @@
|
|
|
|
+using Invercargill.DataStructures;
|
|
|
|
+using Invercargill.Modifiers;
|
|
|
|
+using Invercargill.Mapping;
|
|
|
|
|
|
namespace Invercargill {
|
|
namespace Invercargill {
|
|
|
|
|
|
@@ -84,23 +87,23 @@ namespace Invercargill {
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<T> where(owned PredicateDelegate<T> predicate) {
|
|
public virtual Enumerable<T> where(owned PredicateDelegate<T> predicate) {
|
|
- return new FilterQuery<T>(this, (owned)predicate);
|
|
|
|
|
|
+ return new Filter<T>(this, (owned)predicate);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<T> from(owned PredicateDelegate<T> predicate) {
|
|
public virtual Enumerable<T> from(owned PredicateDelegate<T> predicate) {
|
|
- return new FromQuery<T>(this, (owned)predicate);
|
|
|
|
|
|
+ return new From<T>(this, (owned)predicate);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<T> until(owned PredicateDelegate<T> predicate) {
|
|
public virtual Enumerable<T> until(owned PredicateDelegate<T> predicate) {
|
|
- return new UntilQuery<T>(this, (owned)predicate);
|
|
|
|
|
|
+ return new Until<T>(this, (owned)predicate);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<Tout> select_where<Tout>(owned FilterTransformDelegate<T, Tout> transform) {
|
|
public virtual Enumerable<Tout> select_where<Tout>(owned FilterTransformDelegate<T, Tout> transform) {
|
|
- return new FilterTransformQuery<T, Tout>(this, (owned)transform);
|
|
|
|
|
|
+ return new FilterTransform<T, Tout>(this, (owned)transform);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<Tout> select<Tout>(owned TransformDelegate<T, Tout> transform) {
|
|
public virtual Enumerable<Tout> select<Tout>(owned TransformDelegate<T, Tout> transform) {
|
|
- return new TransformQuery<T, Tout>(this, (owned)transform);
|
|
|
|
|
|
+ return new Transform<T, Tout>(this, (owned)transform);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Attempts<Tout> attempt_select<Tout>(owned AttemptTransformDelegate<T, Tout> transform) {
|
|
public virtual Attempts<Tout> attempt_select<Tout>(owned AttemptTransformDelegate<T, Tout> transform) {
|
|
@@ -123,19 +126,19 @@ namespace Invercargill {
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<T> sort(owned CompareDelegate<T> compare) {
|
|
public virtual Enumerable<T> sort(owned CompareDelegate<T> compare) {
|
|
- return new SortQuery<T>(this, (owned)compare);
|
|
|
|
|
|
+ return new Sort<T>(this, (owned)compare);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<T> concat(Enumerable<T> other) {
|
|
public virtual Enumerable<T> concat(Enumerable<T> other) {
|
|
- return new ConcatEnumerable<T>(this, other);
|
|
|
|
|
|
+ return new Concat<T>(this, other);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<T> take(int count) {
|
|
public virtual Enumerable<T> take(int count) {
|
|
- return new TakeQuery<T>(this, count);
|
|
|
|
|
|
+ return new Take<T>(this, count);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<T> skip(int count) {
|
|
public virtual Enumerable<T> skip(int count) {
|
|
- return new SkipQuery<T>(this, count);
|
|
|
|
|
|
+ return new Skip<T>(this, count);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<Tout> cast<Tout>() {
|
|
public virtual Enumerable<Tout> cast<Tout>() {
|
|
@@ -155,7 +158,7 @@ namespace Invercargill {
|
|
if(actual_workers < 1) {
|
|
if(actual_workers < 1) {
|
|
actual_workers = get_num_processors();
|
|
actual_workers = get_num_processors();
|
|
}
|
|
}
|
|
- return new ParallelQuery<T, Tout>(this, (owned)transform, (int)actual_workers);
|
|
|
|
|
|
+ return new Parallel<T, Tout>(this, (owned)transform, (int)actual_workers);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual int parallel_iterate(ItemDelegate<T> handler, uint workers = 0) {
|
|
public virtual int parallel_iterate(ItemDelegate<T> handler, uint workers = 0) {
|
|
@@ -223,16 +226,21 @@ namespace Invercargill {
|
|
return item;
|
|
return item;
|
|
}
|
|
}
|
|
|
|
|
|
- public virtual bool contains(T item) {
|
|
|
|
- return any(i => i == item);
|
|
|
|
|
|
+ public virtual bool contains(T item, EqualityDelegate<T>? equator = null) {
|
|
|
|
+ var func = equator ?? Operators.equality<T>();
|
|
|
|
+ return any(i => func(i, item));
|
|
}
|
|
}
|
|
|
|
|
|
- public virtual Enumerable<Pair<T, Tother>> pair<Tother>(Enumerable<Tother> other) {
|
|
|
|
- return new PairEnumerable<T, Tother>(this, other);
|
|
|
|
|
|
+ public virtual Enumerable<TOut> zip<TOther, TOut>(Enumerable<TOther> other, owned ZipperTransformDelegate<T, TOther, TOut> transform) {
|
|
|
|
+ return new Zip<T, TOther, TOut>(this, other, (owned)transform);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public virtual Enumerable<Pair<T, Tother>> pair_up<Tother>(Enumerable<Tother> other) {
|
|
|
|
+ return zip<Tother, Pair<T, Tother>>(other, (t1v, t1vs, t2v, t2vs) => new Pair<T, Tother>(t1v, t1vs, t2v, t2vs));
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<T> interleave(Enumerable<T> other) {
|
|
public virtual Enumerable<T> interleave(Enumerable<T> other) {
|
|
- return new ZipperEnumerable<T>(this, other);
|
|
|
|
|
|
+ return new Interleave<T>(this, other);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<Tout> fork<Tout>(owned TransformDelegate<T, Tout> fork1, owned TransformDelegate<T, Tout> fork2) {
|
|
public virtual Enumerable<Tout> fork<Tout>(owned TransformDelegate<T, Tout> fork1, owned TransformDelegate<T, Tout> fork2) {
|
|
@@ -245,7 +253,7 @@ namespace Invercargill {
|
|
}
|
|
}
|
|
|
|
|
|
public virtual bool matches(Enumerable<T> other, EqualityDelegate<T> equals) {
|
|
public virtual bool matches(Enumerable<T> other, EqualityDelegate<T> equals) {
|
|
- return pair(other).all(p => equals(p.value1, p.value2));
|
|
|
|
|
|
+ return zip<T, bool>(other, (t1v, t1vs, t2v, t2vs) => t1vs == t2vs && equals(t1v, t2v)).all(r => r);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<T> act(ItemDelegate<T> handler) {
|
|
public virtual Enumerable<T> act(ItemDelegate<T> handler) {
|
|
@@ -261,7 +269,7 @@ namespace Invercargill {
|
|
|
|
|
|
public virtual Enumerable<T> distinct_by<TProp>(owned TransformDelegate<T, TProp> property_selector, owned EqualityDelegate<TProp>? property_equality) {
|
|
public virtual Enumerable<T> distinct_by<TProp>(owned TransformDelegate<T, TProp> property_selector, owned EqualityDelegate<TProp>? property_equality) {
|
|
var func = property_equality ?? Operators.equality<T>();
|
|
var func = property_equality ?? Operators.equality<T>();
|
|
- return new UniqueByQuery<T, TProp>(this, (owned)property_selector, (owned)func);
|
|
|
|
|
|
+ return new Unique<T, TProp>(this, (owned)property_selector, (owned)func);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<Grouping<TKey, T>> group_by<TKey>(owned TransformDelegate<T, TKey> key_selector, owned EqualityDelegate<TKey>? key_equality = null) {
|
|
public virtual Enumerable<Grouping<TKey, T>> group_by<TKey>(owned TransformDelegate<T, TKey> key_selector, owned EqualityDelegate<TKey>? key_equality = null) {
|
|
@@ -408,17 +416,17 @@ namespace Invercargill {
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<T> seal() {
|
|
public virtual Enumerable<T> seal() {
|
|
- if(this.get_type().is_a(typeof(SealedEnumerable))) {
|
|
|
|
|
|
+ if(this.get_type().is_a(typeof(Sealed))) {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
- return new SealedEnumerable<T>(this);
|
|
|
|
|
|
+ return new Sealed<T>(this);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<T> cache() {
|
|
public virtual Enumerable<T> cache() {
|
|
- if(this.get_type().is_a(typeof(CacheEnumerable))) {
|
|
|
|
|
|
+ if(this.get_type().is_a(typeof(Cache))) {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
- return new CacheEnumerable<T>(this);
|
|
|
|
|
|
+ return new Cache<T>(this);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Dictionary<TKey, T> to_dictionary<TKey>(TransformDelegate<T, TKey> key_selecter, HashDelegate<TKey>? key_hash_func = null, EqualityDelegate<TKey>? key_equal_func = null) {
|
|
public virtual Dictionary<TKey, T> to_dictionary<TKey>(TransformDelegate<T, TKey> key_selecter, HashDelegate<TKey>? key_hash_func = null, EqualityDelegate<TKey>? key_equal_func = null) {
|
|
@@ -440,7 +448,7 @@ namespace Invercargill {
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Enumerable<PositionItemPair<T>> with_positions() {
|
|
public virtual Enumerable<PositionItemPair<T>> with_positions() {
|
|
- return new PositionQuery<T>(this);
|
|
|
|
|
|
+ return new Position<T>(this);
|
|
}
|
|
}
|
|
|
|
|
|
public virtual Elements to_elements() {
|
|
public virtual Elements to_elements() {
|