public void TestMethod1() { var test = (2 + 3) / 2; var test1 = (0 + 3) / 2; var test2 = (0 + 1) / 2; Assert.AreEqual(3, SortedSearch.CountNumbers(new int[] { 1, 3, 5, 7, 8, 10, 12, 7 }, 6)); Assert.AreEqual(1, SortedSearch.CountNumbers(new int[] { 1, 3 }, 2)); Assert.AreEqual(1, SortedSearch.CountNumbers(new int[] { 1 }, 2)); Assert.AreEqual(0, SortedSearch.CountNumbers(new int[] { 1 }, -1)); }
public void SortedSearch_CountNumbers() { // Arrange. SortedSearch sortedSearch = new SortedSearch(); // Act. int actual = sortedSearch.CountNumbers(new int[] { 1, 3, 5, 7 }, 4); // Assert. Assert.AreEqual(2, actual); }
public static void Main(string[] args) { Console.WriteLine(SortedSearch.CountNumbers(new int[] { 1, 3, 5, 7, 8, 9, 11, 13, 15, 20, 25, 27, 28, 29, 30, 45, 50, 51, 52, 55 }, 2)); Console.Read(); }
public void FindAssemblies(Query query, bool defaultToAll = false) { string assemblyName = query.GetSearchTermForAssemblySearch(); if (assemblyName == null) { if (defaultToAll) { query.AddResultAssemblies(GetAllListedAssemblies()); } return; } bool isQuoted = false; assemblyName = Query.StripQuotes(assemblyName, out isQuoted); var search = new SortedSearch(i => this.assemblies[i].AssemblyName, this.assemblies.Count); int low, high; search.FindBounds(assemblyName, out low, out high); if (high >= low) { var result = Enumerable .Range(low, high - low + 1) .Where(i => !isQuoted || assemblies[i].AssemblyName.Length == assemblyName.Length) .Select(i => assemblies[i]) .Where(a => a.ProjectKey != -1) .Take(MaxRawResults) .ToList(); query.AddResultAssemblies(result); } }
private void FindSymbols(Query query, Interpretation interpretation) { string searchTerm = interpretation.CoreSearchTerm; var search = new SortedSearch(i => symbols[i].Name, symbols.Count); int low, high; search.FindBounds(searchTerm, out low, out high); if (high < low) { return; } query.PotentialRawResults = high - low + 1; var result = Enumerable .Range(low, high - low + 1) .Where(i => !interpretation.IsVerbatim || symbols[i].Name.Length == searchTerm.Length) .Select(i => symbols[i].GetDeclaredSymbolInfo(huffman, assemblies, projects)) .Where(query.Filter) .Where(interpretation.Filter) .Take(MaxRawResults) .ToList(); foreach (var entry in result) { entry.MatchLevel = MatchLevel(entry.Name, searchTerm); } query.AddResultSymbols(result); }
private void FindProjects(Query query) { string searchTerm = query.GetSearchTermForProjectSearch(); if (searchTerm == null) { return; } var search = new SortedSearch(i => projects[i], projects.Count); int low, high; search.FindBounds(searchTerm, out low, out high); if (high >= low) { var result = Enumerable .Range(low, high - low + 1) .Select(i => assemblies[projectToAssemblyIndexMap[projects[i]]]) .Take(MaxRawResults) .ToList(); query.AddResultProjects(result); } }
private IEnumerable<string> FindInList(string searchTerm, List<string> list, bool defaultToAll) { if (string.IsNullOrEmpty(searchTerm)) { if (defaultToAll) { return list; } else { return null; } } var search = new SortedSearch(i => list[i], list.Count); int low, high; search.FindBounds(searchTerm, out low, out high); if (high >= low) { var result = Enumerable .Range(low, high - low + 1) .Select(i => list[i]) .Take(MaxRawResults); return result; } return null; }
public static void Main(string[] args) { Console.WriteLine(SortedSearch.CountNumbers(new int[] { 1, 2, 3, 4 }, 4));//Esta funcion busca si existen valores menores a lessThan=4 en el array={ 1,2,3,4 },y devuelve la cantidad de elemntos menores a 4 si los encuentra Console.ReadLine(); }
public static void Main(string[] args) { Console.WriteLine(SortedSearch.CountNumbers(new int[] { 1, 3, 5, 7 }, 4)); }
public void Count_should_count_number_less_than_correctly(int expected, int lessThan, params int[] args) { var result = SortedSearch.CountNumbers(args, lessThan); Assert.Equal(expected, result); }