|
@@ -76,6 +76,10 @@ namespace Invercargill {
|
|
return new Buffer<T>.take_array(to_array());
|
|
return new Buffer<T>.take_array(to_array());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public virtual ImmutableBuffer<T> to_immutable_buffer() {
|
|
|
|
+ return new ImmutableBuffer<T>(this);
|
|
|
|
+ }
|
|
|
|
+
|
|
public virtual RingBuffer<T> to_ring_buffer(uint? size = null) {
|
|
public virtual RingBuffer<T> to_ring_buffer(uint? size = null) {
|
|
if(size == null) {
|
|
if(size == null) {
|
|
return new RingBuffer<T>.take_array(to_array());
|
|
return new RingBuffer<T>.take_array(to_array());
|
|
@@ -333,25 +337,46 @@ namespace Invercargill {
|
|
return keys.select<Grouping<TKey, T>>(g => new Grouping<TKey, T>(g, this.where(i => equality(g, key_selector(i)))));
|
|
return keys.select<Grouping<TKey, T>>(g => new Grouping<TKey, T>(g, this.where(i => equality(g, key_selector(i)))));
|
|
}
|
|
}
|
|
|
|
|
|
- public virtual Enumerable<T> union_by<TKey>(Enumerable<T> other, owned TransformDelegate<T, TKey> key_selector, owned HashDelegate<TKey>? hash_func = null, owned EqualityDelegate<TKey>? equal_func = null) {
|
|
|
|
|
|
+ public virtual Enumerable<T> combine_by<TKey>(Enumerable<T> other, owned TransformDelegate<T, TKey> key_selector, owned HashDelegate<TKey>? hash_func = null, owned EqualityDelegate<TKey>? equal_func = null) {
|
|
return new Union<T, TKey>(this, other, (owned)key_selector, (owned)hash_func, (owned)equal_func);
|
|
return new Union<T, TKey>(this, other, (owned)key_selector, (owned)hash_func, (owned)equal_func);
|
|
}
|
|
}
|
|
|
|
|
|
- // Can't name it union because of C reserved keywords
|
|
|
|
- // New names
|
|
|
|
- // - union: combine or merge
|
|
|
|
- // - intersect: overlap or common
|
|
|
|
- // - difference: exclude or subtract
|
|
|
|
- // - symmetric difference: mismatch or disjoint
|
|
|
|
- public virtual Enumerable<T> union(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
|
|
|
|
- return union_by<T>(other, i => i, (owned)hash_func, (owned) equal_func);
|
|
|
|
|
|
+ public virtual Enumerable<T> combine(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
|
|
|
|
+ return combine_by<T>(other, i => i, (owned)hash_func, (owned) equal_func);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public virtual Enumerable<T> common_by<TKey>(Enumerable<T> other, owned TransformDelegate<T, TKey> key_selector, owned HashDelegate<TKey>? hash_func = null, owned EqualityDelegate<TKey>? equal_func = null) {
|
|
|
|
+ return new Intersect<T, TKey>(this, other, (owned)key_selector, (owned)hash_func, (owned)equal_func);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public virtual Enumerable<T> common(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
|
|
|
|
+ return common_by<T>(other, i => i, (owned)hash_func, (owned) equal_func);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public virtual Enumerable<T> exclude_by<TKey>(Enumerable<T> other, owned TransformDelegate<T, TKey> key_selector, owned HashDelegate<TKey>? hash_func = null, owned EqualityDelegate<TKey>? equal_func = null) {
|
|
|
|
+ return new Difference<T, TKey>(this, other, (owned)key_selector, (owned)hash_func, (owned)equal_func);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public virtual Enumerable<T> exclude(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
|
|
|
|
+ return exclude_by<T>(other, i => i, (owned)hash_func, (owned) equal_func);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public virtual Enumerable<T> non_common_by<TKey>(Enumerable<T> other, owned TransformDelegate<T, TKey> key_selector, owned HashDelegate<TKey>? hash_func = null, owned EqualityDelegate<TKey>? equal_func = null) {
|
|
|
|
+ return new SymmetricDifference<T, TKey>(this, other, (owned)key_selector, (owned)hash_func, (owned)equal_func);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public virtual Enumerable<T> non_common(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
|
|
|
|
+ return non_common_by<T>(other, i => i, (owned)hash_func, (owned) equal_func);
|
|
|
|
+ }
|
|
|
|
|
|
public virtual Enumerable<T> @with(T item, uint times = 1) {
|
|
public virtual Enumerable<T> @with(T item, uint times = 1) {
|
|
return concat(range(0, (int)times, 1).select<T>(i => item));
|
|
return concat(range(0, (int)times, 1).select<T>(i => item));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public virtual Partition<T> partition(PredicateDelegate<T> test) {
|
|
|
|
+ return new Partition<T>(this, test);
|
|
|
|
+ }
|
|
|
|
+
|
|
public virtual T first(owned PredicateDelegate<T>? predicate = null) throws SequenceError {
|
|
public virtual T first(owned PredicateDelegate<T>? predicate = null) throws SequenceError {
|
|
var tracker = predicate == null ? get_tracker() : where((owned)predicate).get_tracker();
|
|
var tracker = predicate == null ? get_tracker() : where((owned)predicate).get_tracker();
|
|
if(tracker.has_next()) {
|
|
if(tracker.has_next()) {
|