public V this[K1 x, K2 y]
        {
            get
            {
                int ix, iy;
                if (!xDimension.TryGetValue(x, out ix) ||
                    !yDimension.TryGetValue(y, out iy) || !used[ix, iy])
                {
                    throw new KeyNotFoundException("Square not found");
                }

                return(values[ix, iy]);
            }
        }
Example #2
0
        public V this[K1 x, K2 y, K3 z]
        {
            get
            {
                int ix, iy, iz;
                if (!xDimension.TryGetValue(x, out ix) ||
                    !yDimension.TryGetValue(y, out iy) ||
                    !zDimension.TryGetValue(z, out iz) || !used[ix, iy, iz])
                {
                    throw new KeyNotFoundException("Cube not found");
                }

                return(values[ix, iy, iz]);
            }
        }
Example #3
0
 public static IntervalDictionary <K, VR> Mix <K, V1, V2, VR>(this IntervalDictionary <K, V1> me, IntervalDictionary <K, V2> other, Func <Interval <K>, IntervalValue <V1>, IntervalValue <V2>, IntervalValue <VR> > mixer)
     where K : struct, IComparable <K>, IEquatable <K>
 {
     Interval <K>[] keys = me.Intervals.Concat(other.Intervals).SelectMany(a => a.Elements()).Distinct().OrderBy().BiSelect((min, max) => new Interval <K>(min, max)).ToArray();
     return(new IntervalDictionary <K, VR>(keys
                                           .Select(k => new { Intervalo = k, Valor = mixer(k, me.TryGetValue(k.Min), other.TryGetValue(k.Min)) })
                                           .Where(a => a.Valor.HasInterval).Select(a => KVP.Create(a.Intervalo, a.Valor.Value))));
 }
Example #4
0
        public static IntervalDictionary <K, VR> Mix <K, V1, V2, VR>(this IntervalDictionary <K, V1> me, IntervalDictionary <K, V2> other, Func <Interval <K>, IntervalValue <V1>, IntervalValue <V2>, IntervalValue <VR> > mixer)
            where K : struct, IComparable <K>, IEquatable <K>
        {
#pragma warning disable CS8629 // Nullable value type may be null. CSBUG
            Interval <K>[] keys = me.Intervals.Concat(other.Intervals).SelectMany(a => a.Elements()).Distinct().OrderBy().BiSelectS((min, max) => new Interval <K>(min.Value, max.Value)).ToArray();
#pragma warning restore CS8629 // Nullable value type may be null.
            return(new IntervalDictionary <K, VR>(keys
                                                  .Select(k => new { Intervalo = k, Valor = mixer(k, me.TryGetValue(k.Min), other.TryGetValue(k.Min)) })
                                                  .Where(a => a.Valor.HasInterval).Select(a => KeyValuePair.Create(a.Intervalo, a.Valor.Value))));
        }