コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 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();
 }
コード例 #4
0
ファイル: Index.cs プロジェクト: rgmills/SourceBrowser
        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);
            }
        }
コード例 #5
0
ファイル: Index.cs プロジェクト: rgmills/SourceBrowser
        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);
        }
コード例 #6
0
ファイル: Index.cs プロジェクト: rgmills/SourceBrowser
        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);
            }
        }
コード例 #7
0
ファイル: Index.cs プロジェクト: rgmills/SourceBrowser
        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;
        }
コード例 #8
0
    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();
    }
コード例 #9
0
 public static void Main(string[] args)
 {
     Console.WriteLine(SortedSearch.CountNumbers(new int[] { 1, 3, 5, 7 }, 4));
 }
コード例 #10
0
        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);
        }