private bool UpdateModified(GitObjectDb.Models.IModelObject old, GitObjectDb.Models.IModelObject @new, System.Collections.Generic.IDictionary <string, System.Collections.Generic.ISet <string> > result) { var oldKeys = new System.Collections.Generic.SortedSet <string>(); var newKeys = new System.Collections.Generic.SortedSet <string>(); ComputeKeys(old, oldKeys); ComputeKeys(@new, newKeys); var path = new Lazy <string>(() => GitObjectDb.Models.IModelObjectExtensions.GetFolderPath(old)); var anyUpdate = false; foreach (var key in System.Linq.Enumerable.Except(oldKeys, newKeys)) { if (key == null) { continue; } var set = GetIndexValues(key, result, create: false); anyUpdate |= set?.Remove(path.Value) ?? false; } foreach (var key in System.Linq.Enumerable.Except(newKeys, oldKeys)) { var set = GetIndexValues(key, result, create: true); anyUpdate |= set.Add(path.Value); } return(anyUpdate); }
private static System.Collections.Generic.ISet <string> GetIndexValues(string key, System.Collections.Generic.IDictionary <string, System.Collections.Generic.ISet <string> > dictionary, bool create) { if (!dictionary.TryGetValue(key, out var result) && create) { dictionary[key] = result = new System.Collections.Generic.SortedSet <string>(); } return(result); }
static void Main() { s = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); long[][] arr = new long[2][]; arr[0] = new long[s[0]]; arr[1] = new long[s[0]]; long ans = long.MaxValue; for (int i = 0; i < s[0]; i++) { long[] q = Array.ConvertAll(Console.ReadLine().Split(), long.Parse); arr[0][i] = q[0]; arr[1][i] = q[1]; } var h1 = new System.Collections.Generic.SortedSet <long>(arr[0]); var h2 = new System.Collections.Generic.SortedSet <long>(arr[1]); long[] x = new long[h1.Count]; long[] y = new long[h2.Count]; h1.CopyTo(x, 0); h2.CopyTo(y, 0); for (int i = 0; i < x.Length - 1; i++) { for (int j = i + 1; j < x.Length; j++) { for (int k = 0; k < y.Length - 1; k++) { for (int l = k + 1; l < y.Length; l++) { int p = 0; for (int m = 0; m < s[0]; m++) { if (arr[0][m] >= x[i] && arr[0][m] <= x[j] && arr[1][m] >= y[k] && arr[1][m] <= y[l]) { p++; if (p == s[1]) { ans = Math.Min(ans, (x[j] - x[i]) * (y[l] - y[k])); break; } } } } } } } Console.WriteLine("{0}", ans); }
private bool UpdateAdded(GitObjectDb.Models.IModelObject node, System.Collections.Generic.IDictionary <string, System.Collections.Generic.ISet <string> > result) { var path = new Lazy <string>(() => GitObjectDb.Models.IModelObjectExtensions.GetFolderPath(node)); var keys = new System.Collections.Generic.SortedSet <string>(); ComputeKeys(node, keys); var anyUpdate = false; foreach (var key in keys) { var set = GetIndexValues(key, result, create: true); anyUpdate |= set.Add(path.Value); } return(anyUpdate); }