public static HMap <A, HMap <B, HMap <C, HMap <D, V> > > > TrySetItemT <A, B, C, D, V>(this HMap <A, HMap <B, HMap <C, HMap <D, V> > > > map, A aKey, B bKey, C cKey, D dKey, Func <V, V> Some) { var a = map.Find(aKey); if (a.IsNone) { return(map); } var av = a.Value; return(map.SetItem(aKey, av.TrySetItemT(bKey, cKey, dKey, Some))); }
public static HMap <A, HMap <B, V> > TrySetItemT <A, B, V>(this HMap <A, HMap <B, V> > map, A aKey, B bKey, V value) { var a = map.Find(aKey); if (a.IsNone) { return(map); } var av = a.Value; return(map.SetItem(aKey, av.TrySetItem(bKey, value))); }
public static HMap <A, HMap <B, HMap <C, HMap <D, V> > > > SetItemT <A, B, C, D, V>(this HMap <A, HMap <B, HMap <C, HMap <D, V> > > > map, A aKey, B bKey, C cKey, D dKey, Func <V, V> Some) { var a = map.Find(aKey); if (a.IsNone) { throw new ArgumentException("Key not found in Map"); } var av = a.Value; return(map.SetItem(aKey, av.SetItemT(bKey, cKey, dKey, Some))); }
public static HMap <A, HMap <B, V> > SetItemT <A, B, V>(this HMap <A, HMap <B, V> > map, A aKey, B bKey, V value) { var a = map.Find(aKey); if (a.IsNone) { throw new ArgumentException("Key not found in Map"); } var av = a.Value; return(map.SetItem(aKey, av.SetItem(bKey, value))); }
public static HMap <A, HMap <B, HMap <C, T> > > Remove <A, B, C, T>(this HMap <A, HMap <B, HMap <C, T> > > self, A aKey, B bKey, C cKey) { var b = self.Find(aKey); if (b.IsSome) { var c = b.Value.Find(bKey); if (c.IsSome) { var cv = c.Value.Remove(cKey); if (cv.Count() == 0) { var bv = b.Value.Remove(bKey); if (b.Value.Count() == 0) { return(self.Remove(aKey)); } else { return(self.SetItem(aKey, bv)); } } else { return(self.SetItem(aKey, b.Value.SetItem(bKey, cv))); } } else { return(self); } } else { return(self); } }
public static HMap <A, HMap <B, T> > Remove <A, B, T>(this HMap <A, HMap <B, T> > self, A outerKey, B innerKey) { var b = self.Find(outerKey); if (b.IsSome) { var bv = b.Value.Remove(innerKey); if (bv.Count() == 0) { return(self.Remove(outerKey)); } else { return(self.SetItem(outerKey, bv)); } } else { return(self); } }