Pārlūkot izejas kodu

Re-sync proxy and siticky proxy

Billy Barrow 4 dienas atpakaļ
vecāks
revīzija
25623ce9fc
2 mainītis faili ar 293 papildinājumiem un 22 dzēšanām
  1. 195 20
      src/lib/Proxy.vala
  2. 98 2
      src/lib/StickyProxy.vala

+ 195 - 20
src/lib/Proxy.vala

@@ -7,6 +7,9 @@ namespace Invercargill {
 
         protected Enumerable<T> inner { get; set; }
 
+        // NOTE: Do not implement debug functions here (debug_type, debug_dump, or debug_trace)
+        // as that will make the proxy invisable to the debug output, and can also cause nasty loops.
+
         public override EnumerableInfo get_info() {
             return new EnumerableInfo.infer_single(this, EnumerableCategory.PROXY, inner);
         }
@@ -38,7 +41,23 @@ namespace Invercargill {
         public override T[] to_array() {
             return inner.to_array();
         }
-    
+        
+        public override Buffer<T> to_buffer() {
+            return inner.to_buffer();
+        }
+        
+        public override ImmutableBuffer<T> to_immutable_buffer() {
+            return inner.to_immutable_buffer();
+        }
+        
+        public override RingBuffer<T> to_ring_buffer(uint? size = null) {
+            return inner.to_ring_buffer(size);
+        }
+        
+        public override ulong count_ulong(PredicateDelegate<T>? predicate = null) {
+            return inner.count_ulong(predicate);
+        }
+        
         public override uint count(PredicateDelegate<T>? predicate = null) {
             return inner.count(predicate);
         }
@@ -110,7 +129,75 @@ namespace Invercargill {
         public override T min(TransformDelegate<T, int> int_delegate) {
             return inner.min(int_delegate);
         }
-    
+        
+        public override Enumerable<T> from(owned PredicateDelegate<T> predicate) {
+            return inner.from((owned)predicate);
+        }
+        
+        public override Enumerable<T> until(owned PredicateDelegate<T> predicate) {
+            return inner.until((owned)predicate);
+        }
+        
+        public override Enumerable<TOut> select_where<TOut>(owned FilterTransformDelegate<T, TOut> transform) {
+            return inner.select_where<TOut>((owned)transform);
+        }
+        
+        public override Attempts<TOut> attempt_select<TOut>(owned AttemptTransformDelegate<T, TOut> transform) {
+            return inner.attempt_select<TOut>((owned)transform);
+        }
+        
+        public override Attempts<SelectionContext<T, TOut>> attempt_contextualised_select<TOut>(owned AttemptTransformDelegate<T, TOut> transform) {
+            return inner.attempt_contextualised_select<TOut>((owned)transform);
+        }
+        
+        public override Attempts<TOut> attempt_select_nested<TOut>(owned AttemptTransformDelegate<T, Enumerable<Attempt<TOut>>> transform) {
+            return inner.attempt_select_nested<TOut>((owned)transform);
+        }
+        
+        public override Attempts<T> attempt_where(owned AttemptPredicate<T> predicate) {
+            return inner.attempt_where((owned)predicate);
+        }
+        
+        public override Enumerable<Pair<TFirst, TSecond>> select_pairs<TFirst, TSecond>(owned TransformDelegate<T, TFirst> transform1, owned TransformDelegate<T, TSecond> transform2) {
+            return inner.select_pairs<TFirst, TSecond>((owned)transform1, (owned)transform2);
+        }
+        
+        public override Enumerable<T> order_by<TKey>(owned TransformDelegate<T, TKey> key_selector, owned CompareDelegate<TKey>? comparitor = null) {
+            return inner.order_by<TKey>((owned)key_selector, (owned)comparitor);
+        }
+        
+        public override Enumerable<T> order_by_descending<TKey>(owned TransformDelegate<T, TKey> key_selector, owned CompareDelegate<TKey>? comparitor = null) {
+            return inner.order_by_descending<TKey>((owned)key_selector, (owned)comparitor);
+        }
+        
+        public override Enumerable<T> order_by_complex(ItemDelegate<OrderConfiguration<T>> config) {
+            return inner.order_by_complex(config);
+        }
+        
+        public override Enumerable<T> skip_last(uint count) {
+            return inner.skip_last(count);
+        }
+        
+        public override Enumerable<T> take_last(uint count) {
+            return inner.take_last(count);
+        }
+        
+        public override Enumerable<TOut> of_type<TOut>() {
+            return inner.of_type<TOut>();
+        }
+        
+        public override Enumerable<T> parallel_where<T>(owned PredicateDelegate<T> predicate, uint workers = 0) {
+            return inner.parallel_where<T>((owned)predicate, workers);
+        }
+        
+        public override Enumerable<SelectionContext<T, TOut>> parallel_contextualised_select<TOut>(owned TransformDelegate<T, TOut> transform) {
+            return inner.parallel_contextualised_select<TOut>((owned)transform);
+        }
+        
+        public override Enumerable<TOut> zip<TOther, TOut>(Enumerable<TOther> other, owned ZipperTransformDelegate<T, TOther, TOut> transform) {
+            return inner.zip<TOther, TOut>(other, (owned)transform);
+        }
+        
         public override bool contains(T item, EqualityDelegate<T>? equator = null) {
             return inner.contains(item, equator);
         }
@@ -134,7 +221,71 @@ namespace Invercargill {
         public override bool matches(Enumerable<T> other, EqualityDelegate<T> equals) {
             return inner.matches(other, equals);
         }
-    
+        
+        public override Enumerable<T> act(ItemDelegate<T> handler) {
+            return inner.act(handler);
+        }
+        
+        public override Enumerable<T> distinct(owned EqualityDelegate<T>? comparison = null) {
+            return inner.distinct((owned)comparison);
+        }
+        
+        public override Enumerable<T> distinct_by<TProp>(owned TransformDelegate<T, TProp> property_selector, owned EqualityDelegate<TProp>? property_equality) {
+            return inner.distinct_by<TProp>((owned)property_selector, (owned)property_equality);
+        }
+        
+        public override Enumerable<Grouping<TKey, T>> group_by<TKey>(owned TransformDelegate<T, TKey> key_selector, owned EqualityDelegate<TKey>? key_equality = null) {
+            return inner.group_by<TKey>((owned)key_selector, (owned)key_equality);
+        }
+        
+        public override 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 inner.combine_by<TKey>(other, (owned)key_selector, (owned)hash_func, (owned)equal_func);
+        }
+        
+        public override Enumerable<T> combine(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
+            return inner.combine(other, (owned)hash_func, (owned)equal_func);
+        }
+        
+        public override 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 inner.common_by<TKey>(other, (owned)key_selector, (owned)hash_func, (owned)equal_func);
+        }
+        
+        public override Enumerable<T> common(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
+            return inner.common(other, (owned)hash_func, (owned)equal_func);
+        }
+        
+        public override 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 inner.exclude_by<TKey>(other, (owned)key_selector, (owned)hash_func, (owned)equal_func);
+        }
+        
+        public override Enumerable<T> exclude(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
+            return inner.exclude(other, (owned)hash_func, (owned)equal_func);
+        }
+        
+        public override 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 inner.non_common_by<TKey>(other, (owned)key_selector, (owned)hash_func, (owned)equal_func);
+        }
+        
+        public override Enumerable<T> non_common(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
+            return inner.non_common(other, (owned)hash_func, (owned)equal_func);
+        }
+        
+        public override Enumerable<T> prefix_with(T item, uint times = 1) {
+            return inner.prefix_with(item, times);
+        }
+        
+        public override Partition<T> partition(PredicateDelegate<T> test) {
+            return inner.partition(test);
+        }
+        
+        public override T element_at(uint index) throws SequenceError {
+            return inner.element_at(index);
+        }
+        
+        public override T? element_at_or_default(uint index) {
+            return inner.element_at_or_default(index);
+        }
+        
         public override Enumerable<T> suffix_with(T item, uint times = 1) {
             return inner.suffix_with(item, times);
         }
@@ -201,10 +352,6 @@ namespace Invercargill {
             return inner.select_to_dictionary<TKey, TValue>(key_selecter, value_selecter, key_hash_func, key_equal_func);
         }
 
-        public override Enumerable<Pair<TFirst, TSecond>> select_pairs<TFirst, TSecond>(owned TransformDelegate<T, TFirst> transform1, owned TransformDelegate<T, TSecond> transform2) {
-            return inner.select_pairs<TFirst, TSecond>((owned) transform1, (owned) transform2);
-        }
-
         public override Enumerable<PositionItemPair<T>> with_positions() {
             return inner.with_positions();
         }
@@ -215,18 +362,6 @@ namespace Invercargill {
             return inner.to_elements();
         }
 
-        public override Enumerable<TOut> select_where<TOut>(owned FilterTransformDelegate<T, TOut> transform) {
-            return inner.select_where<TOut>((owned)transform);
-        }
-
-        public override Attempts<TOut> attempt_select<TOut>(owned AttemptTransformDelegate<T, TOut> transform) {
-            return inner.attempt_select<TOut>((owned)transform);
-        }
-
-        public override Attempts<TOut> attempt_select_nested<TOut>(owned AttemptTransformDelegate<T, Enumerable<Attempt<TOut>>> transform) {
-            return inner.attempt_select_nested<TOut>((owned)transform);
-        }   
-
         public override Enumerable<T> cache() {
             return inner.cache();
         }
@@ -238,7 +373,47 @@ namespace Invercargill {
         public override Enumerable<T> as_enumerable() {
             return inner.as_enumerable();
         }
-
+        
+        public override Enumerable<Enumerable<T>> chunk(uint chunk_size) {
+            return inner.chunk(chunk_size);
+        }
+        
+        public override Enumerable<T> cycle(uint cycles = -1) {
+            return inner.cycle(cycles);
+        }
+        
+        public override Enumerable<Grouping<TKey, T>> group_adjacent_by<TKey>(owned TransformDelegate<T, TKey> key_selector, owned EqualityDelegate<TKey>? key_equality = null) {
+            return inner.group_adjacent_by<TKey>((owned)key_selector, (owned)key_equality);
+        }
+        
+        public override Enumerable<KeyCountPair<TKey>> histogram_by<TKey>(owned TransformDelegate<T, TKey> key_selector, owned EqualityDelegate<TKey>? key_equality = null) {
+            return inner.histogram_by<TKey>((owned)key_selector, (owned)key_equality);
+        }
+        
+        public override Enumerable<KeyCountPair<T>> histogram(owned EqualityDelegate<T>? key_equality = null) {
+            return inner.histogram((owned)key_equality);
+        }
+        
+        public override Enumerable<T> reverse() {
+            return inner.reverse();
+        }
+        
+        public override Enumerable<Enumerable<T>> window(uint window_size) {
+            return inner.window(window_size);
+        }
+        
+        public override Enumerable<T> pad_end(uint minimum_length, T pad_item) {
+            return inner.pad_end(minimum_length, pad_item);
+        }
+        
+        public override Enumerable<T> pad_start(uint minimum_length, T pad_item) {
+            return inner.pad_start(minimum_length, pad_item);
+        }
+        
+        public override Enumerable<TOut> scan<TOut>(TOut initial_value, owned AggregateDelegate<T, TOut> scanning_delegate) {
+            return inner.scan<TOut>(initial_value, (owned)scanning_delegate);
+        }
+    
     }
 
 }

+ 98 - 2
src/lib/StickyProxy.vala

@@ -12,26 +12,82 @@ namespace Invercargill {
             return rewrap(inner.where((owned)predicate));
         }
     
+        public new TEnumerable from(owned PredicateDelegate<T> predicate) {
+            return rewrap(inner.from((owned)predicate));
+        }
+    
+        public new TEnumerable until(owned PredicateDelegate<T> predicate) {
+            return rewrap(inner.until((owned)predicate));
+        }
+    
         public new TEnumerable sort(owned CompareDelegate<T> compare) {
             return rewrap(inner.sort((owned)compare));
         }
     
+        public new TEnumerable order_by<TKey>(owned TransformDelegate<T, TKey> key_selector, owned CompareDelegate<TKey>? comparitor = null) {
+            return rewrap(inner.order_by<TKey>((owned)key_selector, (owned)comparitor));
+        }
+    
+        public new TEnumerable order_by_descending<TKey>(owned TransformDelegate<T, TKey> key_selector, owned CompareDelegate<TKey>? comparitor = null) {
+            return rewrap(inner.order_by_descending<TKey>((owned)key_selector, (owned)comparitor));
+        }
+    
+        public new TEnumerable order_by_complex(ItemDelegate<OrderConfiguration<T>> config) {
+            return rewrap(inner.order_by_complex(config));
+        }
+    
         public new TEnumerable concat(Enumerable<T> other) {
             return rewrap(inner.concat(other));
         }
     
-        public new TEnumerable take(int count) {
+        public new TEnumerable take(uint count) {
             return rewrap(inner.take(count));
         }
     
-        public new TEnumerable skip(int count) {
+        public new TEnumerable skip(uint count) {
             return rewrap(inner.skip(count));
         }
     
+        public new TEnumerable skip_last(uint count) {
+            return rewrap(inner.skip_last(count));
+        }
+    
+        public new TEnumerable take_last(uint count) {
+            return rewrap(inner.take_last(count));
+        }
+    
+        public new TEnumerable distinct(owned EqualityDelegate<T>? comparison = null) {
+            return rewrap(inner.distinct((owned)comparison));
+        }
+    
+        public new TEnumerable distinct_by<TProp>(owned TransformDelegate<T, TProp> property_selector, owned EqualityDelegate<TProp>? property_equality) {
+            return rewrap(inner.distinct_by<TProp>((owned)property_selector, (owned)property_equality));
+        }
+    
+        public new TEnumerable reverse() {
+            return rewrap(inner.reverse());
+        }
+    
+        public new TEnumerable cycle(uint cycles = -1) {
+            return rewrap(inner.cycle(cycles));
+        }
+    
+        public new TEnumerable prefix_with(T item, uint times = 1) {
+            return rewrap(inner.prefix_with(item, times));
+        }
+    
         public new TEnumerable suffix_with(T item, uint times = 1) {
             return rewrap(inner.suffix_with(item, times));
         }
     
+        public new TEnumerable pad_end(uint minimum_length, T pad_item) {
+            return rewrap(inner.pad_end(minimum_length, pad_item));
+        }
+    
+        public new TEnumerable pad_start(uint minimum_length, T pad_item) {
+            return rewrap(inner.pad_start(minimum_length, pad_item));
+        }
+    
         public new TEnumerable seal() {
             return rewrap(inner.seal());
         }
@@ -52,6 +108,46 @@ namespace Invercargill {
             DebugPrinter.print_enumerable_information(get_info(), additional_message, output_func, formatting);
             return recycle();
         }
+        
+        public new TEnumerable 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 rewrap(inner.combine_by<TKey>(other, (owned)key_selector, (owned)hash_func, (owned)equal_func));
+        }
+        
+        public new TEnumerable combine(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
+            return rewrap(inner.combine(other, (owned)hash_func, (owned)equal_func));
+        }
+        
+        public new TEnumerable 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 rewrap(inner.common_by<TKey>(other, (owned)key_selector, (owned)hash_func, (owned)equal_func));
+        }
+        
+        public new TEnumerable common(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
+            return rewrap(inner.common(other, (owned)hash_func, (owned)equal_func));
+        }
+        
+        public new TEnumerable 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 rewrap(inner.exclude_by<TKey>(other, (owned)key_selector, (owned)hash_func, (owned)equal_func));
+        }
+        
+        public new TEnumerable exclude(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
+            return rewrap(inner.exclude(other, (owned)hash_func, (owned)equal_func));
+        }
+        
+        public new TEnumerable 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 rewrap(inner.non_common_by<TKey>(other, (owned)key_selector, (owned)hash_func, (owned)equal_func));
+        }
+        
+        public new TEnumerable non_common(Enumerable<T> other, owned HashDelegate<T>? hash_func = null, owned EqualityDelegate<T>? equal_func = null) {
+            return rewrap(inner.non_common(other, (owned)hash_func, (owned)equal_func));
+        }
+        
+        public new TEnumerable interleave(Enumerable<T> other) {
+            return rewrap(inner.interleave(other));
+        }
+        
+        public new TEnumerable parallel_where<T>(owned PredicateDelegate<T> predicate, uint workers = 0) {
+            return rewrap(inner.parallel_where<T>((owned)predicate, workers));
+        }
 
     }