|
@@ -19,7 +19,7 @@ namespace Invercargill {
|
|
return inner.all(a => a.success);
|
|
return inner.all(a => a.success);
|
|
}
|
|
}
|
|
|
|
|
|
- public bool unwrap_iterate_if(PredicateDelegate<T> handler) throws Error {
|
|
|
|
|
|
+ public new bool iterate_if(PredicateDelegate<T> handler) throws Error {
|
|
var tracker = get_tracker();
|
|
var tracker = get_tracker();
|
|
while(tracker.has_next()) {
|
|
while(tracker.has_next()) {
|
|
var item = tracker.get_next();
|
|
var item = tracker.get_next();
|
|
@@ -35,26 +35,26 @@ namespace Invercargill {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- public void unwrap_iterate(ItemDelegate<T> handler) throws Error {
|
|
|
|
- unwrap_iterate_if(i => {
|
|
|
|
|
|
+ public new void iterate(ItemDelegate<T> handler) throws Error {
|
|
|
|
+ iterate_if(i => {
|
|
handler(i);
|
|
handler(i);
|
|
return true;
|
|
return true;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- public Series<T> unwrap_to_series() throws Error {
|
|
|
|
|
|
+ public new Series<T> to_series() throws Error {
|
|
var series = new Series<T>();
|
|
var series = new Series<T>();
|
|
- unwrap_iterate(i => series.add(i));
|
|
|
|
|
|
+ iterate(i => series.add(i));
|
|
return series;
|
|
return series;
|
|
}
|
|
}
|
|
|
|
|
|
- public Gee.Collection<T> unwrap_to_gee_collection() throws Error {
|
|
|
|
|
|
+ public new Gee.Collection<T> to_gee_collection() throws Error {
|
|
var collection = new Gee.LinkedList<T>();
|
|
var collection = new Gee.LinkedList<T>();
|
|
- unwrap_iterate(i => collection.add(i));
|
|
|
|
|
|
+ iterate(i => collection.add(i));
|
|
return collection;
|
|
return collection;
|
|
}
|
|
}
|
|
|
|
|
|
- public virtual T[] unwrap_to_array() throws Error {
|
|
|
|
|
|
+ public new T[] to_array() throws Error {
|
|
var array = new T[1024];
|
|
var array = new T[1024];
|
|
var index = 0;
|
|
var index = 0;
|
|
foreach (var item in this) {
|
|
foreach (var item in this) {
|
|
@@ -71,43 +71,43 @@ namespace Invercargill {
|
|
return array;
|
|
return array;
|
|
}
|
|
}
|
|
|
|
|
|
- public Vector<T> unwrap_to_vector() throws Error {
|
|
|
|
|
|
+ public new Vector<T> to_vector() throws Error {
|
|
var vector = new Vector<T>();
|
|
var vector = new Vector<T>();
|
|
- unwrap_iterate(i => vector.add(i));
|
|
|
|
|
|
+ iterate(i => vector.add(i));
|
|
return vector;
|
|
return vector;
|
|
}
|
|
}
|
|
|
|
|
|
- public Dictionary<TKey, T> unwrap_to_dictionary<TKey>(TransformDelegate<T, TKey> key_selecter, HashFunc<TKey>? key_hash_func = null, EqualFunc<TKey>? key_equal_func = null) throws Error {
|
|
|
|
|
|
+ public new Dictionary<TKey, T> to_dictionary<TKey>(TransformDelegate<T, TKey> key_selecter, HashFunc<TKey>? key_hash_func = null, EqualFunc<TKey>? key_equal_func = null) throws Error {
|
|
var dict = new Dictionary<TKey, T>(key_hash_func, key_equal_func);
|
|
var dict = new Dictionary<TKey, T>(key_hash_func, key_equal_func);
|
|
- unwrap_iterate(i => dict.set(key_selecter(i), i));
|
|
|
|
|
|
+ iterate(i => dict.set(key_selecter(i), i));
|
|
return dict;
|
|
return dict;
|
|
}
|
|
}
|
|
|
|
|
|
- public Dictionary<TKey, TValue> unwrap_select_to_dictionary<TKey, TValue>(TransformDelegate<T, TKey> key_selecter, TransformDelegate<T, TValue> value_selecter, HashFunc<TKey>? key_hash_func = null, EqualFunc<TKey>? key_equal_func = null) throws Error {
|
|
|
|
|
|
+ public new Dictionary<TKey, TValue> select_to_dictionary<TKey, TValue>(TransformDelegate<T, TKey> key_selecter, TransformDelegate<T, TValue> value_selecter, HashFunc<TKey>? key_hash_func = null, EqualFunc<TKey>? key_equal_func = null) throws Error {
|
|
var dict = new Dictionary<TKey, T>(key_hash_func, key_equal_func);
|
|
var dict = new Dictionary<TKey, T>(key_hash_func, key_equal_func);
|
|
- unwrap_iterate(i => dict.set(key_selecter(i), value_selecter(i)));
|
|
|
|
|
|
+ iterate(i => dict.set(key_selecter(i), value_selecter(i)));
|
|
return dict;
|
|
return dict;
|
|
}
|
|
}
|
|
|
|
|
|
- public Set<T> unwrap_to_set(HashFunc<T>? hash_func = null, EqualFunc<T>? equal_func = null) throws Error {
|
|
|
|
|
|
+ public new Set<T> to_set(HashFunc<T>? hash_func = null, EqualFunc<T>? equal_func = null) throws Error {
|
|
var @set = new Set<T>(hash_func, equal_func);
|
|
var @set = new Set<T>(hash_func, equal_func);
|
|
- unwrap_iterate(i => @set.add(i));
|
|
|
|
|
|
+ iterate(i => @set.add(i));
|
|
return @set;
|
|
return @set;
|
|
}
|
|
}
|
|
|
|
|
|
- public Elements unwrap_to_elements() throws Error {
|
|
|
|
|
|
+ public new Elements to_elements() throws Error {
|
|
var series = new ElementSeries();
|
|
var series = new ElementSeries();
|
|
if(typeof(T).is_a(typeof(Element))) {
|
|
if(typeof(T).is_a(typeof(Element))) {
|
|
- unwrap_iterate(i => series.add((Element)i));
|
|
|
|
|
|
+ iterate(i => series.add((Element)i));
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- unwrap_iterate(i => series.add(new NativeElement<T>(i)));
|
|
|
|
|
|
+ iterate(i => series.add(new NativeElement<T>(i)));
|
|
}
|
|
}
|
|
return series;
|
|
return series;
|
|
}
|
|
}
|
|
|
|
|
|
- public Object[] unwrap_to_object_array() throws Error {
|
|
|
|
- return unwrap_to_vector().to_object_array();
|
|
|
|
|
|
+ public new Object[] to_object_array() throws Error {
|
|
|
|
+ return to_vector().to_object_array();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -115,7 +115,7 @@ namespace Invercargill {
|
|
public new bool any(PredicateDelegate<T> predicate = (i) => true) throws Error {
|
|
public new bool any(PredicateDelegate<T> predicate = (i) => true) throws Error {
|
|
var result = false;
|
|
var result = false;
|
|
var p = resolve_nullable_predicate(predicate);
|
|
var p = resolve_nullable_predicate(predicate);
|
|
- unwrap_iterate_if(i => {
|
|
|
|
|
|
+ iterate_if(i => {
|
|
if(p(i)) {
|
|
if(p(i)) {
|
|
result = true;
|
|
result = true;
|
|
return false;
|
|
return false;
|
|
@@ -136,19 +136,19 @@ namespace Invercargill {
|
|
}
|
|
}
|
|
|
|
|
|
public new Attempts<T> where(owned PredicateDelegate<T> predicate) {
|
|
public new Attempts<T> where(owned PredicateDelegate<T> predicate) {
|
|
- return inner.where(i => !i.success || predicate(i)).promote_to<Attempts<T>>();
|
|
|
|
|
|
+ return inner.where(i => !i.success || predicate(i)).assert_promotion<Attempts<T>>();
|
|
}
|
|
}
|
|
|
|
|
|
public new Attempts<Tout> select<Tout>(owned TransformDelegate<T, Tout> transform) {
|
|
public new Attempts<Tout> select<Tout>(owned TransformDelegate<T, Tout> transform) {
|
|
- return inner.select<Attempt<Tout>>(a => a.success ? new Attempt<Tout>.successful(transform(a.result)) : new Attempt<Tout>.unsuccessful(a.error)).promote_to<Attempts<T>>();
|
|
|
|
|
|
+ return inner.select<Attempt<Tout>>(a => a.success ? new Attempt<Tout>.successful(transform(a.result)) : new Attempt<Tout>.unsuccessful(a.error)).assert_promotion<Attempts<T>>();
|
|
}
|
|
}
|
|
|
|
|
|
public new Attempts<Tout> select_many<Tout>(owned TransformDelegate<T, Enumerable<Tout>> transform) {
|
|
public new Attempts<Tout> select_many<Tout>(owned TransformDelegate<T, Enumerable<Tout>> transform) {
|
|
- return inner.select_many<Attempt<Tout>>(a => a.success ? transform(a.result).select<Attempt<Tout>>(i => new Attempt<Tout>.successful(i)) : Invercargill.single<Attempt<Tout>>(new Attempt<Tout>.unsuccessful(a.error))).promote_to<Attempts<T>>();
|
|
|
|
|
|
+ return inner.select_many<Attempt<Tout>>(a => a.success ? transform(a.result).select<Attempt<Tout>>(i => new Attempt<Tout>.successful(i)) : Invercargill.single<Attempt<Tout>>(new Attempt<Tout>.unsuccessful(a.error))).assert_promotion<Attempts<T>>();
|
|
}
|
|
}
|
|
|
|
|
|
public new Attempts<T> concat(Enumerable<Attempt<T>> other) {
|
|
public new Attempts<T> concat(Enumerable<Attempt<T>> other) {
|
|
- return inner.concat(other).promote_to<Attempts>();
|
|
|
|
|
|
+ return inner.concat(other).assert_promotion<Attempts>();
|
|
}
|
|
}
|
|
|
|
|
|
public new Attempts<Tout> cast<Tout>() {
|
|
public new Attempts<Tout> cast<Tout>() {
|
|
@@ -164,7 +164,7 @@ namespace Invercargill {
|
|
|
|
|
|
public new Tout aggrigate<Tout>(Tout initial, AggrigateDelegate<Tout, T> aggrigate_func) throws Error {
|
|
public new Tout aggrigate<Tout>(Tout initial, AggrigateDelegate<Tout, T> aggrigate_func) throws Error {
|
|
var aggrigate = initial;
|
|
var aggrigate = initial;
|
|
- unwrap_iterate(i => {
|
|
|
|
|
|
+ iterate(i => {
|
|
aggrigate = aggrigate_func(aggrigate, i);
|
|
aggrigate = aggrigate_func(aggrigate, i);
|
|
});
|
|
});
|
|
return aggrigate;
|
|
return aggrigate;
|
|
@@ -225,13 +225,20 @@ namespace Invercargill {
|
|
}
|
|
}
|
|
|
|
|
|
public new Attempts<Tout> select_where<Tout>(owned FilterTransformDelegate<T, Tout> transform) {
|
|
public new Attempts<Tout> select_where<Tout>(owned FilterTransformDelegate<T, Tout> transform) {
|
|
- return inner.select_where<Tout>((a, ref o) => !a.success || transform(a.result, ref o)).promote_to<Attempts<Tout>>();
|
|
|
|
|
|
+ return inner.select_where<Tout>((a, ref o) => !a.success || transform(a.result, ref o)).assert_promotion<Attempts<Tout>>();
|
|
}
|
|
}
|
|
|
|
|
|
public new Attempts<Tout> try_select<Tout>(owned AttemptTransformDelegate<T, Tout> transform) {
|
|
public new Attempts<Tout> try_select<Tout>(owned AttemptTransformDelegate<T, Tout> transform) {
|
|
return inner.try_select<Tout>(a => a.success ? new Attempt<Tout>(() => transform(a.result)) : new Attempt<Tout>.unsuccessful(a.error));
|
|
return inner.try_select<Tout>(a => a.success ? new Attempt<Tout>(() => transform(a.result)) : new Attempt<Tout>.unsuccessful(a.error));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public new Attempts<Tout> try_select_nested<Tout>(owned AttemptTransformDelegate<T, Enumerable<Attempt<Tout>>> transform) {
|
|
|
|
+ return try_select<Enumerable<Attempt<Tout>>>((owned)transform)
|
|
|
|
+ .as_enumerable()
|
|
|
|
+ .select_many<Attempt<Tout>>(a => a.success ? a.result : Invercargill.single<Attempt<Tout>>(new Attempt<Tout>.unsuccessful(a.error)))
|
|
|
|
+ .assert_promotion<Attempts<Tout>>();
|
|
|
|
+ }
|
|
|
|
+
|
|
public new Attempts<Tout> try_map_with<Tout>(Mapper<Tout, T> mapper) {
|
|
public new Attempts<Tout> try_map_with<Tout>(Mapper<Tout, T> mapper) {
|
|
return try_select<Tout>(o => mapper.materialise(o));
|
|
return try_select<Tout>(o => mapper.materialise(o));
|
|
}
|
|
}
|