Browse Source

Long weekend refactors

Billy Barrow 3 weeks ago
parent
commit
89e0abc5f7
79 changed files with 388 additions and 494 deletions
  1. 0 23
      src/lib/Associative/Index.vala
  2. 0 14
      src/lib/Associative/Properties.vala
  3. 3 0
      src/lib/Cache.vala
  4. 7 4
      src/lib/Convert.vala
  5. 0 93
      src/lib/Converter.vala
  6. 1 1
      src/lib/DataStructures/BinaryData.vala
  7. 2 2
      src/lib/DataStructures/Dictionary.vala
  8. 1 1
      src/lib/DataStructures/Fifo.vala
  9. 2 2
      src/lib/DataStructures/HashSet.vala
  10. 10 0
      src/lib/DataStructures/PropertyDictionary.vala
  11. 2 2
      src/lib/DataStructures/Series.vala
  12. 2 2
      src/lib/DataStructures/Vector.vala
  13. 2 0
      src/lib/Delegates.vala
  14. 3 34
      src/lib/Element.vala
  15. 30 22
      src/lib/Enumerable.vala
  16. 7 5
      src/lib/EnumerableProxy.vala
  17. 26 0
      src/lib/Generators/Directory.vala
  18. 2 2
      src/lib/Generators/Empty.vala
  19. 5 5
      src/lib/Generators/Function.vala
  20. 3 3
      src/lib/Generators/Range.vala
  21. 13 0
      src/lib/Interfaces/Elements.vala
  22. 8 0
      src/lib/Interfaces/Lot.vala
  23. 6 0
      src/lib/Interfaces/Properties.vala
  24. 1 1
      src/lib/Interfaces/ReadOnlyAddressable.vala
  25. 1 1
      src/lib/Interfaces/ReadOnlyAssociative.vala
  26. 1 6
      src/lib/Interfaces/ReadOnlyCollection.vala
  27. 1 1
      src/lib/Interfaces/ReadOnlySet.vala
  28. 4 4
      src/lib/Invercargill.vala
  29. 2 2
      src/lib/Mapping/Mapper.vala
  30. 6 5
      src/lib/Mapping/PropertyMapper.vala
  31. 5 5
      src/lib/Mapping/ValueMapper.vala
  32. 4 3
      src/lib/Modifiers/Cache.vala
  33. 3 3
      src/lib/Modifiers/Concat.vala
  34. 4 3
      src/lib/Modifiers/Filter.vala
  35. 4 3
      src/lib/Modifiers/FilterTransform.vala
  36. 4 4
      src/lib/Modifiers/From.vala
  37. 3 3
      src/lib/Modifiers/Interleave.vala
  38. 3 3
      src/lib/Modifiers/Merge.vala
  39. 0 32
      src/lib/Modifiers/PairEnumerable.vala
  40. 5 3
      src/lib/Modifiers/Parallel.vala
  41. 4 3
      src/lib/Modifiers/Position.vala
  42. 0 7
      src/lib/Modifiers/Query.vala
  43. 11 0
      src/lib/Modifiers/Sealed.vala
  44. 0 11
      src/lib/Modifiers/SealedEnumerable.vala
  45. 4 3
      src/lib/Modifiers/Skip.vala
  46. 4 3
      src/lib/Modifiers/Sort.vala
  47. 4 4
      src/lib/Modifiers/Take.vala
  48. 4 3
      src/lib/Modifiers/Transform.vala
  49. 5 3
      src/lib/Modifiers/Unique.vala
  50. 4 4
      src/lib/Modifiers/Until.vala
  51. 30 0
      src/lib/Modifiers/Zip.vala
  52. 1 0
      src/lib/Promotion.vala
  53. 4 1
      src/lib/Promotions/Attempts.vala
  54. 0 0
      src/lib/Promotions/Equatables.vala
  55. 12 12
      src/lib/Promotions/Numbers/Implementations.vala
  56. 1 1
      src/lib/Promotions/Numbers/Numbers.vala
  57. 2 0
      src/lib/Promotions/PropertyGroups.vala
  58. 1 1
      src/lib/StickyPromotion.vala
  59. 56 0
      src/lib/Wrappers/Array.vala
  60. 0 30
      src/lib/Wrappers/ArrayEnumerable.vala
  61. 0 38
      src/lib/Wrappers/DirEnumerable.vala
  62. 3 3
      src/lib/Wrappers/GeeIterable.vala
  63. 4 4
      src/lib/Wrappers/GenericArray.vala
  64. 0 11
      src/lib/Wrappers/SealedEnumerable.vala
  65. 30 30
      src/lib/meson.build
  66. 1 0
      src/tests/Integration/BinaryData.vala
  67. 0 25
      src/tests/Integration/Cache.vala
  68. 2 0
      src/tests/Integration/Dictionary.vala
  69. 2 0
      src/tests/Integration/Numbers.vala
  70. 1 0
      src/tests/Integration/Promotion.vala
  71. 1 0
      src/tests/Integration/PropertyMapper.vala
  72. 2 0
      src/tests/Integration/Series.vala
  73. 2 0
      src/tests/Integration/Vector.vala
  74. 2 0
      src/tests/Speed/Dictionary.vala
  75. 1 0
      src/tests/Speed/Fifo.vala
  76. 1 0
      src/tests/Speed/Series.vala
  77. 1 0
      src/tests/Speed/Set.vala
  78. 1 0
      src/tests/Speed/SpeedTest.vala
  79. 1 0
      src/tests/Speed/Vector.vala

+ 0 - 23
src/lib/Associative/Index.vala

@@ -1,23 +0,0 @@
-
-//  namespace Invercargill {
-
-//      public interface ReadOnlyIndex<TKey, TValue> : Enumerable<KeyValuePair<TKey, Enumerable<TValue>>> {
-
-//          public abstract ReadOnlyIndex<TKey, TValue> less_than(TKey key);
-//          public abstract ReadOnlyIndex<TKey, TValue> less_than_or_equal_to(TKey key);
-//          public abstract ReadOnlyIndex<TKey, TValue> greater_than(TKey key);
-//          public abstract ReadOnlyIndex<TKey, TValue> greater_than_or_equal_to(TKey key);
-//          public abstract ReadOnlyIndex<TKey, TValue> equal_to(TKey key);
-
-//      }
-
-//      public abstract class Index<TKey, TValue> : Associative<TKey, Enumerable<TValue>>, ReadOnlyIndex<TKey, TValue> {
-
-//          public abstract ReadOnlyIndex<TKey, TValue> less_than(TKey key);
-//          public abstract ReadOnlyIndex<TKey, TValue> less_than_or_equal_to(TKey key);
-//          public abstract ReadOnlyIndex<TKey, TValue> greater_than(TKey key);
-//          public abstract ReadOnlyIndex<TKey, TValue> greater_than_or_equal_to(TKey key);
-//          public abstract ReadOnlyIndex<TKey, TValue> equal_to(TKey key);
-//      }
-
-//  }

+ 0 - 14
src/lib/Associative/Properties.vala

@@ -1,14 +0,0 @@
-
-namespace Invercargill {
-
-    public interface Properties : ReadOnlyAssociative<string, Element> {
-        public abstract void set_native<T>(string key, T value, bool? defined = null) throws ElementError;
-    }
-
-    public class PropertiesDictionary : Dictionary<string, Element>, Properties {
-        public void set_native<T>(string key, T value, bool? defined = null) throws ElementError {
-            this[key] = new NativeElement<T>(value, defined);
-        }
-    }
-
-}

+ 3 - 0
src/lib/Cache.vala

@@ -1,3 +1,6 @@
+using Invercargill.DataStructures;
+using Invercargill.Mapping;
+
 namespace Invercargill {
 
     public delegate T CachedGet<T>();

+ 7 - 4
src/lib/Convert.vala

@@ -1,3 +1,6 @@
+using Invercargill.DataStructures;
+using Invercargill.Wrappers;
+
 namespace Invercargill.Convert {
 
     public static Enumerable<T> ate<T>(T[] input) {
@@ -8,15 +11,15 @@ namespace Invercargill.Convert {
         //      return new GeeEnumerable<T>(gee);
         //  }
 
-        return new ArrayEnumerable<T>(input);
+        return new Wrappers.Array<T>(input);
     }
 
-    public static Enumerable<T> gate<T>(GenericArray<T> input) {
-        return new GenericArrayEnumerable<T>(input);
+    public static Enumerable<T> gate<T>(GLib.GenericArray<T> input) {
+        return new Wrappers.GenericArray<T>(input);
     }
 
     public static Enumerable<T> gte<T>(Gee.Iterable<T> input) {
-        return new GeeEnumerable<T>(input);
+        return new GeeIterable<T>(input);
     }
 
     public static BinaryData batbd(uint8[] input) {

+ 0 - 93
src/lib/Converter.vala

@@ -1,93 +0,0 @@
-
-//  namespace Invercargill {
-
-//      [GenericAccessors]
-//      public interface Converter<TSource, TDestination> : Object {
-        
-//          public virtual Type source_type() {
-//              return typeof(TSource);
-//          }
-
-//          public virtual Type destination_type() {
-//              return typeof(TDestination);
-//          }
-
-//          public abstract TDestination convert(TSource source);
-
-//      }
-
-//      private static Dictionary<ConverterKey, Converter> converter_registry = null;
-
-//      private static void ensure_converter_registry() {
-//          if(converter_registry == null) {
-//              converter_registry = new Dictionary<ConverterKey, Converter>();
-            
-//          }
-//      }
-
-//      public static void register_converter(Converter converter) {
-//          ensure_converter_registry();
-//          converter_registry.set(new ConverterKey.from_converter(converter), converter);
-//      }
-
-//      public static void register_converter_func<TSource, TDestination>(TransformDelegate<TSource, TDestination> func) {
-//          register_converter(new LambdaConverter<TSource, TDestination>(func));
-//      }
-    
-//      public static Converter? get_converter_for_types(Type source, Type destination) {
-//          ensure_converter_registry();
-//          return converter_registry.get_or_default(new ConverterKey(source, destination));
-//      }
-
-//      public static Converter? get_converter<TSource, TDestination>() {
-//          return get_converter_for_types(typeof(TSource), typeof(TDestination));
-//      }
-
-//      public static TDestination convert<TSource, TDestination>(TSource source) throws ConverterError {
-//          var converter = get_converter<TSource, TDestination>();
-//          if(converter == null) {
-//              throw new ConverterError.CONVERTER_NOT_FOUND(@"No converter registered that can convert from $(typeof(TSource).name()) to $(typeof(TDestination).name())");
-//          }
-//          return ((Converter<TSource, TDestination>)converter).convert(source);
-//      }
-
-//      private class ConverterKey : Hashable, Equatable<ConverterKey> {
-//          public Type source { get; set; }
-//          public Type destination { get; set; }
-
-//          public uint hash_code() {
-//              return @"$(source.name())>$(destination.name())".hash();
-//          }
-//          public bool equals(ConverterKey other) {
-//              return
-//                  source == other.source &&
-//                  destination == other.destination;
-//          }
-
-//          public ConverterKey(Type src, Type dst) {
-//              source = src;
-//              destination = dst;
-//          }
-
-//          public ConverterKey.from_converter(Converter converter) {
-//              source = converter.source_type();
-//              destination = converter.destination_type();
-//          }
-
-//      }
-
-//      private class LambdaConverter<TSource, TDestination> : Object, Converter<TSource, TDestination> {
-
-//          private TransformDelegate<TSource, TDestination> func;
-
-//          public LambdaConverter(TransformDelegate<TSource, TDestination> function) {
-//              func = function;
-//          }
-
-//          public TDestination convert(TSource source) {
-//              return func(source);
-//          }
-
-//      }
-
-//  }

+ 1 - 1
src/lib/Collections/BinaryData.vala → src/lib/DataStructures/BinaryData.vala

@@ -1,6 +1,6 @@
 using Invercargill.Convert;
 
-namespace Invercargill {
+namespace Invercargill.DataStructures {
 
     public class BinaryData : Enumerable<uint8>, Promotion<uint8>, Equatable<Enumerable<uint8>>, Hashable {
 

+ 2 - 2
src/lib/Associative/Dictionary.vala → src/lib/DataStructures/Dictionary.vala

@@ -1,8 +1,8 @@
 using Invercargill.Convert;
 
-namespace Invercargill {
+namespace Invercargill.DataStructures {
 
-    public class Dictionary<TKey, TValue> : Enumerable<KeyValuePair<TKey, TValue>>, ReadOnlyCollection<KeyValuePair<TKey, TValue>>, ReadOnlyAssociative<TKey, TValue>, Associative<TKey, TValue> {
+    public class Dictionary<TKey, TValue> : Enumerable<KeyValuePair<TKey, TValue>>, Lot<KeyValuePair<TKey, TValue>>, ReadOnlyCollection<KeyValuePair<TKey, TValue>>, ReadOnlyAssociative<TKey, TValue>, Associative<TKey, TValue> {
 
         private HashSet<KeyValuePair<TKey, TValue>> hash_set;
         private HashDelegate<TKey> hash_func;

+ 1 - 1
src/lib/Collections/Fifo.vala → src/lib/DataStructures/Fifo.vala

@@ -1,4 +1,4 @@
-namespace Invercargill {
+namespace Invercargill.DataStructures {
 
     public class Fifo<T> : Enumerable<T> {
 

+ 2 - 2
src/lib/Collections/HashSet.vala → src/lib/DataStructures/HashSet.vala

@@ -1,8 +1,8 @@
 using Invercargill.Convert;
 
-namespace Invercargill {
+namespace Invercargill.DataStructures {
 
-    public class HashSet<T> : Enumerable<T>, ReadOnlyCollection<T>, ReadOnlySet<T>, Set<T> {
+    public class HashSet<T> : Enumerable<T>, Lot<T>, ReadOnlyCollection<T>, ReadOnlySet<T>, Set<T> {
 
         private const uint BUCKET_TOMBSTONE = uint.MAX;
         private const uint BUCKET_EMPTY = 0;

+ 10 - 0
src/lib/DataStructures/PropertyDictionary.vala

@@ -0,0 +1,10 @@
+
+namespace Invercargill.DataStructures {
+
+    public class PropertyDictionary : Dictionary<string, Element>, Properties {
+        public void set_native<T>(string key, T value) throws ElementError {
+            this[key] = new NativeElement<T>(value);
+        }
+    }
+
+}

+ 2 - 2
src/lib/Collections/Series.vala → src/lib/DataStructures/Series.vala

@@ -1,6 +1,6 @@
-namespace Invercargill {
+namespace Invercargill.DataStructures {
 
-    public class Series<T> : Enumerable<T>, ReadOnlyCollection<T>, Collection<T> {
+    public class Series<T> : Enumerable<T>, Lot<T>, ReadOnlyCollection<T>, Collection<T> {
      
         internal class SeriesItem<T> {
             public SeriesItem next = null;

+ 2 - 2
src/lib/Collections/Vector.vala → src/lib/DataStructures/Vector.vala

@@ -1,6 +1,6 @@
-namespace Invercargill {
+namespace Invercargill.DataStructures {
 
-    public class Vector<T> : Enumerable<T>, ReadOnlyCollection<T>, ReadOnlyAddressable<T>, Collection<T>, Addressable<T> {
+    public class Vector<T> : Enumerable<T>, Lot<T>, ReadOnlyCollection<T>, ReadOnlyAddressable<T>, Collection<T>, Addressable<T> {
 
         private T[] array;
         private int n_items = 0;

+ 2 - 0
src/lib/Delegates.vala

@@ -6,6 +6,8 @@ namespace Invercargill {
 
     public delegate Tout TransformDelegate<Tin, Tout>(Tin item);
 
+    public delegate TOut ZipperTransformDelegate<TFirst, TSecond, TOut>(TFirst? item1, bool item1_is_null, TSecond? item2, bool item2_is_null);
+
     public delegate bool PredicateDelegate<T>(T item);
 
     public delegate Taggregate AggregateDelegate<Taggregate, Tin>(Taggregate aggregate, Tin item);

+ 3 - 34
src/lib/Element.vala

@@ -1,35 +1,6 @@
+using Invercargill.DataStructures;
 namespace Invercargill {
     
-
-    // TODO: Reform Datum to have a type, and add specific to_x functions, with perhaps a to<T> convenience function.
-    // all of these can return errors
-    // int as_int()                             for type NUMBER
-    // int64 as_int64()                         for type NUMBER
-    // uint64 as_uint64()                       for type NUMBER
-    // ...
-    // string as_string()                       for type STRING or NUMBER
-    // Enumerable<Datum> as_enumerable()        for type ENUMERABLE
-    // KeyValues<Datum, Datum> as_keyvalues()   for type KEY_VALUES or PROPERTIES
-    // Properties as_properties()               for type PROPERTIES
-
-    // Add mappable interface with
-    // protected PropertyMapper
-    // public Properties to_properties()
-    // public void populate(Properties props)
-
-
-    public interface Elements : Enumerable<Element> {
-
-        public virtual Enumerable<T> elements_as<T>() {
-            return select_where<T>((e, ref r) => e.try_get_as<T>(out r));
-        }
-
-        public virtual Enumerable<T> assert_elements_as<T>() {
-            return select<T>(e => e.assert_as<T>());
-        }
-
-    }
-    
     private class ElementSeries : Series<Element>, Elements {}
 
 
@@ -92,11 +63,9 @@ namespace Invercargill {
     public class NativeElement<T> : Object, Element {
 
         private T object;
-        private bool nullable;
         
-        public NativeElement(T obj, bool nullable = false) {
+        public NativeElement(T obj) {
             object = obj;
-            this.nullable = nullable;
         }
 
         public bool assignable_to_type(GLib.Type type) {
@@ -114,7 +83,7 @@ namespace Invercargill {
         }
 
         public bool is_null() {
-            return nullable && object == null;
+            return false;
         }
 
         public bool try_get_as<TOut>(out TOut result) {

+ 30 - 22
src/lib/Enumerable.vala

@@ -1,3 +1,6 @@
+using Invercargill.DataStructures;
+using Invercargill.Modifiers;
+using Invercargill.Mapping;
 
 namespace Invercargill {
 
@@ -84,23 +87,23 @@ namespace Invercargill {
         }
 
         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) {
-            return new FromQuery<T>(this, (owned)predicate);
+            return new From<T>(this, (owned)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) {
-            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) {
-            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) {
@@ -123,19 +126,19 @@ namespace Invercargill {
         }
 
         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) {
-            return new ConcatEnumerable<T>(this, other);
+            return new Concat<T>(this, other);
         }
 
         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) {
-            return new SkipQuery<T>(this, count);
+            return new Skip<T>(this, count);
         }
 
         public virtual Enumerable<Tout> cast<Tout>() {
@@ -155,7 +158,7 @@ namespace Invercargill {
             if(actual_workers < 1) {
                 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) {
@@ -223,16 +226,21 @@ namespace Invercargill {
             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) {
-            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) {
@@ -245,7 +253,7 @@ namespace Invercargill {
         }
 
         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) {
@@ -261,7 +269,7 @@ namespace Invercargill {
 
         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>();
-            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) {
@@ -408,17 +416,17 @@ namespace Invercargill {
         }
 
         public virtual Enumerable<T> seal() {
-            if(this.get_type().is_a(typeof(SealedEnumerable))) {
+            if(this.get_type().is_a(typeof(Sealed))) {
                 return this;
             }
-            return new SealedEnumerable<T>(this);
+            return new Sealed<T>(this);
         }
 
         public virtual Enumerable<T> cache() {
-            if(this.get_type().is_a(typeof(CacheEnumerable))) {
+            if(this.get_type().is_a(typeof(Cache))) {
                 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) {
@@ -440,7 +448,7 @@ namespace Invercargill {
         }
 
         public virtual Enumerable<PositionItemPair<T>> with_positions() {
-            return new PositionQuery<T>(this);
+            return new Position<T>(this);
         }
 
         public virtual Elements to_elements() {

+ 7 - 5
src/lib/EnumerableProxy.vala

@@ -1,7 +1,9 @@
+using Invercargill.DataStructures;
+using Invercargill.Mapping;
 
 namespace Invercargill {
 
-    public abstract class ProxyEnumerable<T> : Enumerable<T> {
+    public abstract class EnumerableProxy<T> : Enumerable<T> {
 
         protected Enumerable<T> inner { get; set; }
 
@@ -105,12 +107,12 @@ namespace Invercargill {
             return inner.min(int_delegate);
         }
     
-        public override bool contains(T item) {
-            return inner.contains(item);
+        public override bool contains(T item, EqualityDelegate<T>? equator = null) {
+            return inner.contains(item, equator);
         }
     
-        public override Enumerable<Pair<T, Tother>> pair<Tother>(Enumerable<Tother> other) {
-            return inner.pair(other);
+        public override Enumerable<Pair<T, Tother>> pair_up<Tother>(Enumerable<Tother> other) {
+            return inner.pair_up(other);
         }
     
         public override Enumerable<T> interleave(Enumerable<T> other) {

+ 26 - 0
src/lib/Generators/Directory.vala

@@ -0,0 +1,26 @@
+
+namespace Invercargill.Generators {
+
+    internal class Directory : Enumerable<string> {
+
+        private Dir dir;
+
+        public Directory(owned Dir dir) {
+            this.dir = (owned)dir;
+        }
+
+        public override Tracker<string> get_tracker() {
+            return new AdvanceTracker<string>((out obj) => {
+                var name = dir.read_name();
+                if(name != null) {
+                    obj = name;
+                    return true;
+                }
+                obj = null;
+                return false;
+            });
+        }
+
+    }
+
+}

+ 2 - 2
src/lib/Generators/EmptyEnumerable.vala → src/lib/Generators/Empty.vala

@@ -1,7 +1,7 @@
 
-namespace Invercargill {
+namespace Invercargill.Generators {
 
-    internal class EmptyEnumerable<T> : Enumerable<T> {
+    internal class Empty<T> : Enumerable<T> {
 
         public override Tracker<T> get_tracker() {
             return new LambdaTracker<T>(

+ 5 - 5
src/lib/Generators/Generator.vala → src/lib/Generators/Function.vala

@@ -1,10 +1,10 @@
-namespace Invercargill {
+namespace Invercargill.Generators {
 
-    public delegate GeneratorResult<T> GeneratorFunc<T>();
+    public delegate GeneratorResult<T> GeneratorDelegate<T>();
 
-    public class Generator<T> : Enumerable<T> {
+    public class Function<T> : Enumerable<T> {
 
-        private GeneratorFunc<T> func;
+        private GeneratorDelegate<T> func;
         private bool completed = false;
         private GeneratorResult<T>? next_result = null;
 
@@ -35,7 +35,7 @@ namespace Invercargill {
             }
         }
 
-        public Generator(owned GeneratorFunc<T> generator) {
+        public Function(owned GeneratorDelegate<T> generator) {
             func = (owned)generator;
         }
 

+ 3 - 3
src/lib/Generators/RangeEnumerable.vala → src/lib/Generators/Range.vala

@@ -1,13 +1,13 @@
 
-namespace Invercargill {
+namespace Invercargill.Generators {
 
-    internal class RangeEnumerable : Enumerable<int> {
+    internal class Range : Enumerable<int> {
 
         private int start;
         private int stride;
         private int stop;
 
-        public RangeEnumerable(int initial, int end, int stride) {
+        public Range(int initial, int end, int stride) {
             start = initial;
             stop = end;
             this.stride = stride;

+ 13 - 0
src/lib/Interfaces/Elements.vala

@@ -0,0 +1,13 @@
+namespace Invercargill {
+    public interface Elements : Enumerable<Element> {
+
+        public virtual Enumerable<T> elements_as<T>() {
+            return select_where<T>((e, ref r) => e.try_get_as<T>(out r));
+        }
+
+        public virtual Enumerable<T> assert_elements_as<T>() {
+            return select<T>(e => e.assert_as<T>());
+        }
+
+    }
+}

+ 8 - 0
src/lib/Interfaces/Lot.vala

@@ -0,0 +1,8 @@
+namespace Invercargill {
+
+    [GenericAccessors]
+    public interface Lot<T> : Enumerable<T> {
+
+    }
+
+}

+ 6 - 0
src/lib/Interfaces/Properties.vala

@@ -0,0 +1,6 @@
+namespace Invercargill {
+    public interface Properties : Associative<string, Element> {
+        public abstract void set_native<T>(string key, T value) throws ElementError;
+    }
+
+}

+ 1 - 1
src/lib/Interfaces/ReadOnlyAddressable.vala

@@ -1,7 +1,7 @@
 namespace Invercargill {
 
     [GenericAccessors]
-    public interface ReadOnlyAddressable<T> : ReadOnlyCollection<T> {
+    public interface ReadOnlyAddressable<T> : Lot<T> {
 
         public abstract T @get(uint index) throws IndexError;
         public abstract bool try_get(uint index, out T value);

+ 1 - 1
src/lib/Interfaces/ReadOnlyAssociative.vala

@@ -1,7 +1,7 @@
 namespace Invercargill {
 
     [GenericAccessors]
-    public interface ReadOnlyAssociative<TKey, TValue> : ReadOnlyCollection<KeyValuePair<TKey, TValue>> {
+    public interface ReadOnlyAssociative<TKey, TValue> : Lot<KeyValuePair<TKey, TValue>> {
 
         public abstract bool try_get(TKey key, out TValue value);
         public abstract bool has(TKey key);

+ 1 - 6
src/lib/Interfaces/ReadOnlyCollection.vala

@@ -1,13 +1,8 @@
 namespace Invercargill {
 
     [GenericAccessors]
-    public interface ReadOnlyCollection<T> : Enumerable<T> {
+    public interface ReadOnlyCollection<T> : Lot<T> {
         
-        public virtual bool contains(T item, EqualityDelegate<T>? equator = null) {
-            var func = equator ?? Operators.equality<T>();
-            return any(i => func(i, item));
-        }
-
     }
 
 }

+ 1 - 1
src/lib/Interfaces/ReadOnlySet.vala

@@ -1,7 +1,7 @@
 namespace Invercargill {
 
     [GenericAccessors]
-    public interface ReadOnlySet<T> : ReadOnlyCollection<T> {
+    public interface ReadOnlySet<T> : Lot<T> {
 
         public abstract bool has(T item);
         public abstract bool try_find(T search, out T item);

+ 4 - 4
src/lib/Invercargill.vala

@@ -2,15 +2,15 @@
 namespace Invercargill {
 
     public static Enumerable<int> range(int from, int to, int increment = 1) {
-        return new RangeEnumerable(from, to, increment);
+        return new Generators.Range(from, to, increment);
     }
 
     public static Enumerable<T> empty<T>() {
-        return new EmptyEnumerable<T>();
+        return new Generators.Empty<T>();
     }
 
     public static Enumerable<T> single<T>(T item) {
-        var seq = new Invercargill.Series<T>();
+        var seq = new Invercargill.DataStructures.Series<T>();
         seq.add(item);
         return seq;
     }
@@ -38,7 +38,7 @@ namespace Invercargill {
     }
 
     public static Enumerable<string> directory(string path, uint flags = 0) throws FileError {
-        return new DirEnumerable(Dir.open(path, flags));
+        return new Generators.Directory(Dir.open(path, flags));
     }
 
 }

+ 2 - 2
src/lib/Mapper.vala → src/lib/Mapping/Mapper.vala

@@ -1,6 +1,6 @@
-namespace Invercargill {
+namespace Invercargill.Mapping {
 
-    public abstract class Mapper<TNative, TElement> {
+    public abstract interface Mapper<TNative, TElement> : Object {
 
         public abstract TNative materialise(TElement element) throws Error;
         public abstract TElement map_from(TNative native) throws Error;

+ 6 - 5
src/lib/PropertyMapper.vala → src/lib/Mapping/PropertyMapper.vala

@@ -1,4 +1,5 @@
-namespace Invercargill {
+using Invercargill.DataStructures;
+namespace Invercargill.Mapping {
 
     public delegate TProp PropertyGetter<TClass, TProp>(TClass object) throws Error;
     public delegate bool PropertyPredicate<TClass>(TClass object);
@@ -7,7 +8,7 @@ namespace Invercargill {
     public delegate Tout PropertyGetterTransformer<Tin, Tout>(Tin object);
     public delegate Tout PropertySetterTransformer<Tin, Tout>(Tin object) throws Error;
     public delegate T ObjectConstructor<T>();
-    public class PropertyMapper<T> : Mapper<T, Properties> {
+    public class PropertyMapper<T> : Object, Mapper<T, Properties> {
 
         private Vector<PropertyMapping<T>> mappings;
         private ObjectConstructor<T> constructor;
@@ -48,14 +49,14 @@ namespace Invercargill {
             }
         }
 
-        public override T materialise(Properties properties) throws Error {
+        public T materialise(Properties properties) throws Error {
             var obj = constructor();
             map_into(obj, properties);
             return obj;
         }
 
-        public override Properties map_from(T object) throws Error {
-            var properties = new PropertiesDictionary();
+        public Properties map_from(T object) throws Error {
+            var properties = new PropertyDictionary();
             foreach (var mapping in mappings) {
                 // Check undefined
                 if(mapping.undefined_check != null && mapping.undefined_check(object)){

+ 5 - 5
src/lib/ValueMapper.vala → src/lib/Mapping/ValueMapper.vala

@@ -1,16 +1,16 @@
+using Invercargill.DataStructures;
+namespace Invercargill.Mapping {
 
-namespace Invercargill {
-
-    public class ValueMapper<TNative, TElement> : Mapper<TNative, TElement> {
+    public class ValueMapper<TNative, TElement> : Object, Mapper<TNative, TElement> {
 
         private Dictionary<TNative, TElement> nte { get; set; }
         private Dictionary<TElement, TNative> etn { get; set; }
 
-        public override TNative materialise (TElement element) throws IndexError {
+        public TNative materialise (TElement element) throws IndexError {
             return etn.get(element);
         }
 
-        public override TElement map_from (TNative native) throws IndexError {
+        public TElement map_from (TNative native) throws IndexError {
             return nte.get(native);
         }
 

+ 4 - 3
src/lib/Modifiers/CacheEnumerable.vala → src/lib/Modifiers/Cache.vala

@@ -1,12 +1,13 @@
-namespace Invercargill {
+using Invercargill.DataStructures;
+namespace Invercargill.Modifiers {
 
-    private class CacheEnumerable<T> : Enumerable<T> {
+    public class Cache<T> : Enumerable<T> {
 
         private Vector<T> vector;
         private Enumerable<T> inner;
         private Tracker<T> inner_tracker;
 
-        public CacheEnumerable(Enumerable<T> inner) {
+        public Cache(Enumerable<T> inner) {
             this.inner = inner;
             inner_tracker = this.inner.get_tracker();
             vector = new Vector<T>();

+ 3 - 3
src/lib/Modifiers/ConcatEnumerable.vala → src/lib/Modifiers/Concat.vala

@@ -1,12 +1,12 @@
 
-namespace Invercargill {
+namespace Invercargill.Modifiers {
 
-    private class ConcatEnumerable<T> : Enumerable<T> {
+    public class Concat<T> : Enumerable<T> {
 
         private Enumerable<T> e1;
         private Enumerable<T> e2;
 
-        public ConcatEnumerable(Enumerable<T> first, Enumerable<T> second) {
+        public Concat(Enumerable<T> first, Enumerable<T> second) {
             e1 = first;
             e2 = second;
         }

+ 4 - 3
src/lib/Modifiers/Filter.vala

@@ -1,9 +1,10 @@
-namespace Invercargill {
+namespace Invercargill.Modifiers {
 
-    private class FilterQuery<T> : BaseQuery<T, T> {
+    public class Filter<T> : Enumerable<T> {
         private PredicateDelegate<T> predicate_func;
+        private Enumerable<T> input;
 
-        public FilterQuery(Enumerable<T> input, owned PredicateDelegate<T> func) {
+        public Filter(Enumerable<T> input, owned PredicateDelegate<T> func) {
             this.input = input;
             predicate_func = (owned)func;
         }

+ 4 - 3
src/lib/Modifiers/FilterTransform.vala

@@ -1,9 +1,10 @@
-namespace Invercargill {
+namespace Invercargill.Modifiers {
 
-    private class FilterTransformQuery<Tin, Tout> : BaseQuery<Tin, Tout> {
+    public class FilterTransform<Tin, Tout> : Enumerable<Tout> {
+        private Enumerable<Tin> input;
         private FilterTransformDelegate<Tin, Tout> transform_func;
 
-        public FilterTransformQuery(Enumerable<Tin> input, owned FilterTransformDelegate<Tin, Tout> func) {
+        public FilterTransform(Enumerable<Tin> input, owned FilterTransformDelegate<Tin, Tout> func) {
             this.input = input;
             transform_func = (owned)func;
         }

+ 4 - 4
src/lib/Modifiers/From.vala

@@ -1,10 +1,10 @@
-namespace Invercargill {
-
-    private class FromQuery<T> : BaseQuery<T, T> {
+namespace Invercargill.Modifiers {
 
+    public class From<T> : Enumerable<T> {
+        private Enumerable<T> input;
         private PredicateDelegate<T> predicate_func;
 
-        public FromQuery(Enumerable<T> input, owned PredicateDelegate<T> func) {
+        public From(Enumerable<T> input, owned PredicateDelegate<T> func) {
             this.input = input;
             predicate_func = (owned)func;
         }

+ 3 - 3
src/lib/Modifiers/ZipperEnumerable.vala → src/lib/Modifiers/Interleave.vala

@@ -1,11 +1,11 @@
-namespace Invercargill {
+namespace Invercargill.Modifiers {
 
-    private class ZipperEnumerable<T> : Enumerable<T> {
+    public class Interleave<T> : Enumerable<T> {
 
         private Enumerable<T> e1;
         private Enumerable<T> e2;
 
-        public ZipperEnumerable(Enumerable<T> en1, Enumerable<T> en2) {
+        public Interleave(Enumerable<T> en1, Enumerable<T> en2) {
             e1 = en1;
             e2 = en2;
         }

+ 3 - 3
src/lib/Modifiers/Merge.vala

@@ -1,7 +1,7 @@
-namespace Invercargill {
-
-    private class MergeQuery<T> : BaseQuery<Enumerable<T>, T> {
+namespace Invercargill.Modifiers {
 
+    public class MergeQuery<T> : Enumerable<T> {
+        private Enumerable<Enumerable<T>> input;
         public MergeQuery(Enumerable<Enumerable<T>> input) {
             this.input = input;
         }

+ 0 - 32
src/lib/Modifiers/PairEnumerable.vala

@@ -1,32 +0,0 @@
-namespace Invercargill {
-
-    private class PairEnumerable<T1, T2> : Enumerable<Pair<T1, T2>> {
-
-        private Enumerable<T1> e1;
-        private Enumerable<T2> e2;
-
-        public PairEnumerable(Enumerable<T1> en1, Enumerable<T2> en2) {
-            e1 = en1;
-            e2 = en2;
-        }
-
-        public override Tracker<Pair<T1, T2>> get_tracker() {
-            var tracker1 = e1.get_tracker();
-            var tracker2 = e2.get_tracker();
-
-            return new LambdaTracker<Pair<T1, T2>>(
-                () => tracker1.has_next() || tracker2.has_next(),
-                () => {
-                    var t1vs = tracker1.has_next();
-                    var t2vs = tracker2.has_next();
-                    return new Pair<T1, T2>(
-                        t1vs ? tracker1.get_next() : null,
-                        t1vs,
-                        t2vs ? tracker2.get_next() : null,
-                        t2vs);
-                });
-        }
-
-    }
-
-}

+ 5 - 3
src/lib/Modifiers/Parallel.vala

@@ -1,10 +1,12 @@
-namespace Invercargill {
+using Invercargill.DataStructures;
+namespace Invercargill.Modifiers {
 
-    private class ParallelQuery<Tin, Tout> : BaseQuery<Tin, Tout> {
+    public class Parallel<Tin, Tout> : Enumerable<Tout>{
         private TransformDelegate<Tin, Tout> transform_func;
+        private Enumerable<Tin> input;
         private int workers;
 
-        public ParallelQuery(Enumerable<Tin> input, owned TransformDelegate<Tin, Tout> transform, int workers) {
+        public Parallel(Enumerable<Tin> input, owned TransformDelegate<Tin, Tout> transform, int workers) {
             this.input = input;
             this.workers = workers;
             transform_func = (owned)transform;

+ 4 - 3
src/lib/Modifiers/Position.vala

@@ -1,8 +1,9 @@
-namespace Invercargill {
+namespace Invercargill.Modifiers {
 
-    private class PositionQuery<T> : BaseQuery<T, PositionItemPair<T>> {
+    public class Position<T> : Enumerable<PositionItemPair<T>> {
 
-        public PositionQuery(Enumerable<T> input) {
+        private Enumerable<T> input;
+        public Position(Enumerable<T> input) {
             this.input = input;
         }
 

+ 0 - 7
src/lib/Modifiers/Query.vala

@@ -1,7 +0,0 @@
-namespace Invercargill {
-
-    private abstract class BaseQuery<Tin, Tout> : Enumerable<Tout> {
-        internal Enumerable<Tin> input {get; set;}
-    }
-
-}

+ 11 - 0
src/lib/Modifiers/Sealed.vala

@@ -0,0 +1,11 @@
+namespace Invercargill.Modifiers {
+
+    public class Sealed<T> : EnumerableProxy<T> {
+
+        public Sealed (Enumerable<T> source) {
+            inner = source;
+        }
+
+    }
+
+}

+ 0 - 11
src/lib/Modifiers/SealedEnumerable.vala

@@ -1,11 +0,0 @@
-namespace Invercargill {
-
-    private class SealedEnumerable<T> : ProxyEnumerable<T> {
-
-        public SealedEnumerable (Enumerable<T> source) {
-            inner = source;
-        }
-
-    }
-
-}

+ 4 - 3
src/lib/Modifiers/Skip.vala

@@ -1,10 +1,11 @@
-namespace Invercargill {
+namespace Invercargill.Modifiers {
 
-    private class SkipQuery<T> : BaseQuery<T, T> {
+    public class Skip<T> : Enumerable<T> {
 
+        private Enumerable<T> input;
         private int n_items {get; set;}
 
-        public SkipQuery(Enumerable<T> input, int skip) {
+        public Skip(Enumerable<T> input, int skip) {
             this.input = input;
             n_items = skip;
         }

+ 4 - 3
src/lib/Modifiers/Sort.vala

@@ -1,9 +1,10 @@
-namespace Invercargill {
+namespace Invercargill.Modifiers {
 
-    private class SortQuery<T> : BaseQuery<T, T> {
+    public class Sort<T> : Enumerable<T> {
+        private Enumerable<T> input;
         private CompareDelegate<T> compare_func;
 
-        public SortQuery(Enumerable<T> input, owned CompareDelegate<T> compare) {
+        public Sort(Enumerable<T> input, owned CompareDelegate<T> compare) {
             this.input = input;
             compare_func = (owned)compare;
         }

+ 4 - 4
src/lib/Modifiers/Take.vala

@@ -1,10 +1,10 @@
-namespace Invercargill {
-
-    private class TakeQuery<T> : BaseQuery<T, T> {
+namespace Invercargill.Modifiers {
 
+    public class Take<T> : Enumerable<T> {
+        private Enumerable<T> input;
         private int n_items {get; set;}
 
-        public TakeQuery(Enumerable<T> input, int count) {
+        public Take(Enumerable<T> input, int count) {
             this.input = input;
             n_items = count;
         }

+ 4 - 3
src/lib/Modifiers/Transform.vala

@@ -1,9 +1,10 @@
-namespace Invercargill {
+namespace Invercargill.Modifiers {
 
-    private class TransformQuery<Tin, Tout> : BaseQuery<Tin, Tout> {
+    public class Transform<Tin, Tout> : Enumerable<Tout> {
+        private Enumerable<Tin> input;
         private TransformDelegate<Tin, Tout> transform_func;
 
-        public TransformQuery(Enumerable<Tin> input, owned TransformDelegate<Tin, Tout> transform) {
+        public Transform(Enumerable<Tin> input, owned TransformDelegate<Tin, Tout> transform) {
             this.input = input;
             transform_func = (owned)transform;
         }

+ 5 - 3
src/lib/Modifiers/Unique.vala

@@ -1,10 +1,12 @@
-namespace Invercargill {
+using Invercargill.DataStructures;
+namespace Invercargill.Modifiers {
 
-    private class UniqueByQuery<T, TProp> : BaseQuery<T, T> {
+    public class Unique<T, TProp> : Enumerable<T> {
+        private Enumerable<T> input;
         private EqualityDelegate<TProp> comparison;
         private TransformDelegate<T, TProp> selector;
 
-        public UniqueByQuery(Enumerable<T> input, owned TransformDelegate<T, TProp> selector, owned EqualityDelegate<TProp> compare) {
+        public Unique(Enumerable<T> input, owned TransformDelegate<T, TProp> selector, owned EqualityDelegate<TProp> compare) {
             this.input = input;
             comparison = (owned)compare;
             this.selector = (owned)selector;

+ 4 - 4
src/lib/Modifiers/Until.vala

@@ -1,10 +1,10 @@
-namespace Invercargill {
-
-    private class UntilQuery<T> : BaseQuery<T, T> {
+namespace Invercargill.Modifiers {
 
+    public class Until<T> : Enumerable<T> {
+        private Enumerable<T> input;
         private PredicateDelegate<T> predicate_func;
 
-        public UntilQuery(Enumerable<T> input, owned PredicateDelegate<T> func) {
+        public Until(Enumerable<T> input, owned PredicateDelegate<T> func) {
             this.input = input;
             predicate_func = (owned)func;
         }

+ 30 - 0
src/lib/Modifiers/Zip.vala

@@ -0,0 +1,30 @@
+namespace Invercargill.Modifiers {
+
+    public class Zip<TFirst, TSecond, TOut> : Enumerable<TOut> {
+
+        private Enumerable<TFirst> e1;
+        private Enumerable<TSecond> e2;
+        private ZipperTransformDelegate<TFirst, TSecond, TOut> transform_func;
+
+        public Zip(Enumerable<TFirst> en1, Enumerable<TSecond> en2, owned ZipperTransformDelegate<TFirst, TSecond, TOut> func) {
+            e1 = en1;
+            e2 = en2;
+            transform_func = (owned)func;
+        }
+
+        public override Tracker<TOut> get_tracker() {
+            var tracker1 = e1.get_tracker();
+            var tracker2 = e2.get_tracker();
+
+            return new LambdaTracker<TOut>(
+                () => tracker1.has_next() || tracker2.has_next(),
+                () => {
+                    var t1vs = tracker1.has_next();
+                    var t2vs = tracker2.has_next();
+                    return transform_func(t1vs ? tracker1.get_next() : null, t1vs, t2vs ? tracker2.get_next() : null, t2vs);
+                });
+        }
+
+    }
+
+}

+ 1 - 0
src/lib/Promotion.vala

@@ -1,3 +1,4 @@
+using Invercargill.DataStructures;
 namespace Invercargill {
 
     private static Dictionary<Type, Type> promotion_registry = null;

+ 4 - 1
src/lib/Promotions/AttemptEnumerable.vala → src/lib/Promotions/Attempts.vala

@@ -1,6 +1,9 @@
+using Invercargill.DataStructures;
+using Invercargill.Mapping;
+
 namespace Invercargill {
 
-    public class Attempts<T> : ProxyEnumerable<Attempt<T>>, Promotion<Attempt<T>> {
+    public class Attempts<T> : EnumerableProxy<Attempt<T>>, Promotion<Attempt<T>> {
 
         public Enumerable<Attempt<T>> wrap (Enumerable<Attempt<T>> enumerable) {
             inner = enumerable;

+ 0 - 0
src/lib/Promotions/EquatableEnumerable.vala → src/lib/Promotions/Equatables.vala


+ 12 - 12
src/lib/Promotions/Numbers/Implementations.vala

@@ -1,6 +1,6 @@
 namespace Invercargill {
 
-    public class SignedNativeIntegers : NumberEnumerable<int, SignedNativeIntegers> {
+    public class SignedNativeIntegers : Numbers<int, SignedNativeIntegers> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(int));
         }
@@ -33,7 +33,7 @@ namespace Invercargill {
         }        
     }
 
-    public class UnsignedNativeIntegers : NumberEnumerable<uint, UnsignedNativeIntegers> {
+    public class UnsignedNativeIntegers : Numbers<uint, UnsignedNativeIntegers> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(uint));
         }
@@ -66,7 +66,7 @@ namespace Invercargill {
         }      
     }
 
-    public class Signed8BitIntegers : NumberEnumerable<int8, Signed8BitIntegers> {
+    public class Signed8BitIntegers : Numbers<int8, Signed8BitIntegers> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(int8));
         }
@@ -99,7 +99,7 @@ namespace Invercargill {
         }      
     }
 
-    public class Unsigned8BitIntegers : NumberEnumerable<uint8, Unsigned8BitIntegers> {
+    public class Unsigned8BitIntegers : Numbers<uint8, Unsigned8BitIntegers> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(uint8));
         }
@@ -132,7 +132,7 @@ namespace Invercargill {
         }      
     }
 
-    public class Signed16BitIntegers : NumberEnumerable<int16, Signed16BitIntegers> {
+    public class Signed16BitIntegers : Numbers<int16, Signed16BitIntegers> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(int16));
         }
@@ -165,7 +165,7 @@ namespace Invercargill {
         }      
     }
 
-    public class Unsigned16BitIntegers : NumberEnumerable<uint16, Unsigned16BitIntegers> {
+    public class Unsigned16BitIntegers : Numbers<uint16, Unsigned16BitIntegers> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(uint16));
         }
@@ -198,7 +198,7 @@ namespace Invercargill {
         }      
     }
 
-    public class Signed32BitIntegers : NumberEnumerable<int32, Signed32BitIntegers> {
+    public class Signed32BitIntegers : Numbers<int32, Signed32BitIntegers> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(int32));
         }
@@ -231,7 +231,7 @@ namespace Invercargill {
         }      
     }
 
-    public class Unsigned32BitIntegers : NumberEnumerable<uint32, Unsigned32BitIntegers> {
+    public class Unsigned32BitIntegers : Numbers<uint32, Unsigned32BitIntegers> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(uint32));
         }
@@ -264,7 +264,7 @@ namespace Invercargill {
         }      
     }
 
-    public class Signed64BitIntegers : NumberEnumerable<int64?, Signed64BitIntegers> {
+    public class Signed64BitIntegers : Numbers<int64?, Signed64BitIntegers> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(int64?));
         }
@@ -297,7 +297,7 @@ namespace Invercargill {
         }      
     }
 
-    public class Unsigned64BitIntegers : NumberEnumerable<uint64?, Unsigned64BitIntegers> {
+    public class Unsigned64BitIntegers : Numbers<uint64?, Unsigned64BitIntegers> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(uint64?));
         }
@@ -330,7 +330,7 @@ namespace Invercargill {
         }      
     }
 
-    public class Doubles : NumberEnumerable<double?, Doubles> {
+    public class Doubles : Numbers<double?, Doubles> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(double?));
         }
@@ -363,7 +363,7 @@ namespace Invercargill {
         }      
     }
 
-    public class Floats : NumberEnumerable<float?, Floats> {
+    public class Floats : Numbers<float?, Floats> {
         public override bool can_wrap(GLib.Type element_type) {
             return element_type.is_a(typeof(float?));
         }

+ 1 - 1
src/lib/Promotions/Numbers/NumberEnumerable.vala → src/lib/Promotions/Numbers/Numbers.vala

@@ -1,6 +1,6 @@
 namespace Invercargill {
 
-    public abstract class NumberEnumerable<T, TSelf> : StickyPromotion<T, TSelf>, Promotion<T>, Equatable<Enumerable<T>> {
+    public abstract class Numbers<T, TSelf> : StickyPromotion<T, TSelf>, Promotion<T>, Equatable<Enumerable<T>> {
 
         protected abstract bool greater_than(T a, T b);
         protected abstract bool less_than(T a, T b);

+ 2 - 0
src/lib/Promotions/PropertyGroupEnumerable.vala → src/lib/Promotions/PropertyGroups.vala

@@ -1,3 +1,5 @@
+using Invercargill.Mapping;
+
 namespace Invercargill {
 
     public class PropertyGroups : StickyPromotion<Properties, PropertyGroups>, Promotion<Properties> {

+ 1 - 1
src/lib/StickyPromotion.vala

@@ -1,6 +1,6 @@
 namespace Invercargill {
 
-    public abstract class StickyPromotion<T, TPromotion> : ProxyEnumerable<T>, Promotion<T> {
+    public abstract class StickyPromotion<T, TPromotion> : EnumerableProxy<T>, Promotion<T> {
 
         public abstract Enumerable<T> wrap(Enumerable<T> enumerable);
         public abstract bool can_wrap(GLib.Type element_type);

+ 56 - 0
src/lib/Wrappers/Array.vala

@@ -0,0 +1,56 @@
+
+namespace Invercargill.Wrappers {
+
+    public class Array<T> : Enumerable<T>, Lot<T>, ReadOnlyAddressable<T> {
+
+        private T[] array;
+
+        public Array(T[] input) {
+            array = new T[input.length];
+            for(uint i = 0; i < array.length; i++) {
+                safely_assign_to_array<T>(array, i, safely_read_array<T>(input, i));
+            }
+        }
+
+        public override Tracker<T> get_tracker() {
+            var i = 0;
+            return new LambdaTracker<T>(
+                () => {
+                    return i < array.length;
+                },
+                () => {
+                    var res = safely_read_array<T>(array, i);
+                    i++;
+                    return res;
+                });
+        }
+
+        public new T get(uint index) throws IndexError {
+            if(index >= array.length) {
+                throw new IndexError.INDEX_EXCEEDS_UPPER_BOUNDS(@"Tried to access index $(index) on a wrapped array with $(array.length) item(s)");
+            }
+            return safely_read_array<T>(array, index);
+        }
+
+        public bool try_get(uint index, out T value) {
+            if(index >= array.length) {
+                value = null;
+                return false;
+            }
+            value = safely_read_array<T>(array, index);
+            return true;
+        }
+
+        public uint? first_index_of(Invercargill.PredicateDelegate<T> predicate) {
+            for(uint i = 0; i < array.length; i++) {
+                var item = safely_read_array<T>(array, i);
+                if(predicate(item)) {
+                    return i;
+                }
+            }
+            return null;
+        }
+
+    }
+
+}

+ 0 - 30
src/lib/Wrappers/ArrayEnumerable.vala

@@ -1,30 +0,0 @@
-
-namespace Invercargill {
-
-    internal class ArrayEnumerable<T> : Enumerable<T> {
-
-        private T[] array;
-
-        public ArrayEnumerable(T[] input) {
-            array = new T[input.length];
-            for(int i = 0; i < array.length; i++) {
-                safely_assign_to_array<T> (array, i, safely_read_array<T> (input, i));
-            }
-        }
-
-        public override Tracker<T> get_tracker() {
-            var i = 0;
-            return new LambdaTracker<T>(
-                () => {
-                    return i < array.length;
-                },
-                () => {
-                    var res = safely_read_array(array, i);
-                    i++;
-                    return res;
-                });
-        }
-
-    }
-
-}

+ 0 - 38
src/lib/Wrappers/DirEnumerable.vala

@@ -1,38 +0,0 @@
-
-namespace Invercargill {
-
-    internal class DirEnumerable : Enumerable<string> {
-
-        private Dir dir;
-
-        public DirEnumerable(owned Dir dir) {
-            this.dir = (owned)dir;
-        }
-
-        //  public override bool iterate_if (Invercargill.PredicateDelegate<T> handler) {
-        //      string? name = null;
-        //      while ((name = dir.read_name ()) != null) {
-        //          if(!handler(name)) {
-        //              dir.rewind();
-        //              return false;
-        //          }
-        //      }
-        //      dir.rewind();
-        //      return true;
-        //  }
-
-        public override Tracker<string> get_tracker() {
-            return new AdvanceTracker<string>((out obj) => {
-                var name = dir.read_name();
-                if(name != null) {
-                    obj = name;
-                    return true;
-                }
-                obj = null;
-                return false;
-            });
-        }
-
-    }
-
-}

+ 3 - 3
src/lib/Wrappers/GeeEnumerable.vala → src/lib/Wrappers/GeeIterable.vala

@@ -1,13 +1,13 @@
 
 using Gee;
 
-namespace Invercargill {
+namespace Invercargill.Wrappers {
 
-    private class GeeEnumerable<T> : Enumerable<T> {
+    private class GeeIterable<T> : Enumerable<T> {
 
         private Iterable<T> iterable;
 
-        public GeeEnumerable(Iterable<T> gee) {
+        public GeeIterable(Iterable<T> gee) {
             iterable = gee;
         }
 

+ 4 - 4
src/lib/Wrappers/GenericArrayEnumerable.vala → src/lib/Wrappers/GenericArray.vala

@@ -1,11 +1,11 @@
 
-namespace Invercargill {
+namespace Invercargill.Wrappers {
 
-    internal class GenericArrayEnumerable<T> : Enumerable<T> {
+    public class GenericArray<T> : Enumerable<T> {
 
-        private GenericArray<T> array;
+        private GLib.GenericArray<T> array;
 
-        public GenericArrayEnumerable(GenericArray<T> input) {
+        public GenericArray(GLib.GenericArray<T> input) {
             array = input;
         }
 

+ 0 - 11
src/lib/Wrappers/SealedEnumerable.vala

@@ -1,11 +0,0 @@
-namespace Invercargill {
-
-    public class SealedEnumerable<T> : ProxyEnumerable<T> {
-
-        public SealedEnumerable (Enumerable<T> source) {
-            inner = source;
-        }
-
-    }
-
-}

+ 30 - 30
src/lib/meson.build

@@ -19,18 +19,13 @@ sources += files('Safety.vala')
 sources += files('Promotion.vala')
 sources += files('Grouping.vala')
 sources += files('Interfaces.vala')
-sources += files('Element.vala')
-sources += files('Converter.vala')
-sources += files('Mapper.vala')
-sources += files('PropertyMapper.vala')
-sources += files('ValueMapper.vala')
 sources += files('KeyValuePair.vala')
 sources += files('Attempt.vala')
 sources += files('Cache.vala')
 sources += files('EnumerableProxy.vala')
 sources += files('StickyPromotion.vala')
+sources += files('Element.vala')
 
-sources += files('Modifiers/Query.vala')
 sources += files('Modifiers/Transform.vala')
 sources += files('Modifiers/Filter.vala')
 sources += files('Modifiers/Merge.vala')
@@ -43,27 +38,28 @@ sources += files('Modifiers/Position.vala')
 sources += files('Modifiers/FilterTransform.vala')
 sources += files('Modifiers/From.vala')
 sources += files('Modifiers/Until.vala')
-sources += files('Modifiers/CacheEnumerable.vala')
-sources += files('Modifiers/ConcatEnumerable.vala')
-sources += files('Modifiers/PairEnumerable.vala')
-sources += files('Modifiers/SealedEnumerable.vala')
-sources += files('Modifiers/ZipperEnumerable.vala')
+sources += files('Modifiers/Cache.vala')
+sources += files('Modifiers/Concat.vala')
+sources += files('Modifiers/Zip.vala')
+sources += files('Modifiers/Sealed.vala')
+sources += files('Modifiers/Interleave.vala')
 
-sources += files('Wrappers/ArrayEnumerable.vala')
-sources += files('Wrappers/GeeEnumerable.vala')
-sources += files('Wrappers/GenericArrayEnumerable.vala')
-sources += files('Wrappers/DirEnumerable.vala')
+sources += files('Wrappers/Array.vala')
+sources += files('Wrappers/GeeIterable.vala')
+sources += files('Wrappers/GenericArray.vala')
 
-sources += files('Generators/RangeEnumerable.vala')
-sources += files('Generators/EmptyEnumerable.vala')
-sources += files('Generators/Generator.vala')
+sources += files('Generators/Range.vala')
+sources += files('Generators/Empty.vala')
+sources += files('Generators/Function.vala')
+sources += files('Generators/Directory.vala')
 
-sources += files('Promotions/Numbers/NumberEnumerable.vala')
+sources += files('Promotions/Numbers/Numbers.vala')
 sources += files('Promotions/Numbers/Implementations.vala')
-sources += files('Promotions/EquatableEnumerable.vala')
-sources += files('Promotions/AttemptEnumerable.vala')
-sources += files('Promotions/PropertyGroupEnumerable.vala')
+sources += files('Promotions/Equatables.vala')
+sources += files('Promotions/Attempts.vala')
+sources += files('Promotions/PropertyGroups.vala')
 
+sources += files('Interfaces/Lot.vala')
 sources += files('Interfaces/ReadOnlyCollection.vala')
 sources += files('Interfaces/ReadOnlyAssociative.vala')
 sources += files('Interfaces/ReadOnlyAddressable.vala')
@@ -72,16 +68,20 @@ sources += files('Interfaces/Collection.vala')
 sources += files('Interfaces/Associative.vala')
 sources += files('Interfaces/Addressable.vala')
 sources += files('Interfaces/Set.vala')
+sources += files('Interfaces/Properties.vala')
+sources += files('Interfaces/Elements.vala')
 
-sources += files('Collections/Series.vala')
-sources += files('Collections/Fifo.vala')
-sources += files('Collections/BinaryData.vala')
-sources += files('Collections/Vector.vala')
-sources += files('Collections/HashSet.vala')
+sources += files('DataStructures/Series.vala')
+sources += files('DataStructures/Fifo.vala')
+sources += files('DataStructures/BinaryData.vala')
+sources += files('DataStructures/Vector.vala')
+sources += files('DataStructures/HashSet.vala')
+sources += files('DataStructures/Dictionary.vala')
+sources += files('DataStructures/PropertyDictionary.vala')
 
-sources += files('Associative/Dictionary.vala')
-sources += files('Associative/Index.vala')
-sources += files('Associative/Properties.vala')
+sources += files('Mapping/Mapper.vala')
+sources += files('Mapping/PropertyMapper.vala')
+sources += files('Mapping/ValueMapper.vala')
 
 sources += files('Operators/Comparison.vala')
 sources += files('Operators/Equality.vala')

+ 1 - 0
src/tests/Integration/BinaryData.vala

@@ -1,5 +1,6 @@
 using Invercargill;
 using Invercargill.Convert;
+using Invercargill.DataStructures;
 
 void binary_data_tests() {
 

+ 0 - 25
src/tests/Integration/Cache.vala

@@ -5,11 +5,6 @@ void cache_tests() {
 
 
     Test.add_func("/invercargill/operator/cache", () => {
-
-        print("Cl1\n");
-        new Cl1<int>();
-        
-        print("Done\n");
         var runs = 0;
         var enumerable = range(0, 64).act(() => runs++).cache().assert_promotion<SignedNativeIntegers>();
 
@@ -38,24 +33,4 @@ void cache_tests() {
 
     });
 
-}
-
-class Cl1<T> : Enumerable<T>, ReadOnlyCollection<T>, Collection<T> {
-    public void add(T item) {
-        assert_not_reached();
-    }
-    public void clear() {
-        assert_not_reached();
-    }
-    public void remove_all_where(Invercargill.PredicateDelegate<T> predicate) {
-        assert_not_reached();
-    }
-    public void remove_first_where(Invercargill.PredicateDelegate<T> predicate) {
-        assert_not_reached();
-    }
-    public override Invercargill.Tracker<T> get_tracker() {
-        assert_not_reached();
-    }
-
-
 }

+ 2 - 0
src/tests/Integration/Dictionary.vala

@@ -1,5 +1,7 @@
 using Invercargill;
 using Invercargill.Convert;
+using Invercargill.DataStructures;
+
 
 void dictionary_tests() {
 

+ 2 - 0
src/tests/Integration/Numbers.vala

@@ -1,5 +1,7 @@
 using Invercargill;
 using Invercargill.Convert;
+using Invercargill.DataStructures;
+
 
 void numbers_test() {
 

+ 1 - 0
src/tests/Integration/Promotion.vala

@@ -1,5 +1,6 @@
 using Invercargill;
 using Invercargill.Convert;
+using Invercargill.DataStructures;
 
 void promotion_tests() {
 

+ 1 - 0
src/tests/Integration/PropertyMapper.vala

@@ -1,5 +1,6 @@
 using Invercargill;
 using Invercargill.Convert;
+using Invercargill.Mapping;
 
 void property_mapper_tests() {
 

+ 2 - 0
src/tests/Integration/Series.vala

@@ -1,5 +1,7 @@
 using Invercargill;
 using Invercargill.Convert;
+using Invercargill.DataStructures;
+
 
 void series_tests() {
 

+ 2 - 0
src/tests/Integration/Vector.vala

@@ -1,5 +1,7 @@
 using Invercargill;
 using Invercargill.Convert;
+using Invercargill.DataStructures;
+
 
 void vector_tests() {
 

+ 2 - 0
src/tests/Speed/Dictionary.vala

@@ -1,4 +1,6 @@
 using Invercargill;
+using Invercargill.DataStructures;
+
 
 void dictionary_speed_test() {
     var dict = new Dictionary<int, int>();

+ 1 - 0
src/tests/Speed/Fifo.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.DataStructures;
 
 void fifo_speed_test() {
     var fifo = new Fifo<int>();

+ 1 - 0
src/tests/Speed/Series.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.DataStructures;
 
 void series_speed_test() {
     var series = new Series<int>();

+ 1 - 0
src/tests/Speed/Set.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.DataStructures;
 
 void set_speed_test() {
     var @set = new HashSet<int>();

+ 1 - 0
src/tests/Speed/SpeedTest.vala

@@ -1,5 +1,6 @@
 
 using Invercargill;
+using Invercargill.DataStructures;
 
 delegate void AddDelegate<T>(T item);
 delegate void BulkAddDelegate<T>(Invercargill.Enumerable<T> items);

+ 1 - 0
src/tests/Speed/Vector.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.DataStructures;
 
 void vector_speed_test() {
     var vec = new Vector<int>();