当前位置: 首页>>代码示例>>C#>>正文


C# Quote.le方法代码示例

本文整理汇总了C#中Quote.le方法的典型用法代码示例。如果您正苦于以下问题:C# Quote.le方法的具体用法?C# Quote.le怎么用?C# Quote.le使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Quote的用法示例。


在下文中一共展示了Quote.le方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    static public void Main(string[] args)
    {
        Storage db = StorageFactory.Instance.CreateStorage();
        db.Open("testkdtree.dbs", pagePoolSize);
        int n;

#if USE_GENERICS
        MultidimensionalIndex<Quote> index = (MultidimensionalIndex<Quote>)db.Root;
        if (index == null) { 
            index = db.CreateMultidimensionalIndex<Quote>(new string[] { "low", "high", "open", "close", "volume" }, false);
            db.Root = index;
        }
#else
        MultidimensionalIndex index = (MultidimensionalIndex)db.Root;
        if (index == null) { 
            index = db.CreateMultidimensionalIndex(typeof(Quote), new string[] { "low", "high", "open", "close", "volume" }, false);
            db.Root = index;
        }
#endif
        DateTime start = DateTime.Now; 
        Random r = new Random(2007);
        for (int i = 0; i < nRecords; i++) { 
            Quote q = getRandomQuote(r);
            index.Add(q);
        }
        db.Commit();
        Console.WriteLine("Elapsed time for inserting " + nRecords + " records: " + (DateTime.Now - start));
		
        Console.WriteLine("Tree height: " + index.Height);
        if (index.Count > 1 && index.Height/Math.Log(index.Count)*Math.Log(2.0) > KD_TREE_OPTIMIZATION_THRESHOLD) { 
            start = DateTime.Now; 
            index.Optimize();
            Console.WriteLine("New tree height: " + index.Height);
            Console.WriteLine("Elapsed time for tree optimization: " + (DateTime.Now - start));
        }

        start = System.DateTime.Now;
        r = new Random(2007);
        for (int i = 0; i < nRecords; i++) {
            Quote q = getRandomQuote(r);            
#if USE_GENERICS
            Quote[] result = index.QueryByExample(q);
            Debug.Assert(result.Length >= 1);
            for (int j = 0; j < result.Length; j++) { 
                Debug.Assert(q.eq(result[j]));
            }
#else
            object[] result = index.QueryByExample(q);
            Debug.Assert(result.Length >= 1);
            for (int j = 0; j < result.Length; j++) { 
                Debug.Assert(q.eq((Quote)result[j]));
            }
#endif
        }
        Console.WriteLine("Elapsed time for performing " + nRecords + " query by example searches: " + (DateTime.Now - start));

        start = System.DateTime.Now;
        r = new Random(2007);
        Random r2 = new Random(2008);
        long total = 0;
        for (int i = 0; i < nRecords; i++) {
            Quote q = getRandomQuote(r);            
            Quote min = new Quote();
            Quote max = new Quote();

            min.low = q.low - (float)MAX_PRICE/EPSILON;
            min.high = q.high - (float)MAX_PRICE/EPSILON;
            min.open = q.open - (float)MAX_PRICE/EPSILON;
            min.close = q.close - (float)MAX_PRICE/EPSILON;
            min.volume = q.volume - MAX_VOLUME/EPSILON;

            max.low = q.low + (float)MAX_PRICE/EPSILON;
            max.high = q.high + (float)MAX_PRICE/EPSILON;
            max.open = q.open + (float)MAX_PRICE/EPSILON;
            max.close = q.close + (float)MAX_PRICE/EPSILON;
            max.volume = q.volume + MAX_VOLUME/EPSILON;

            n = 0;
            foreach (Quote quote in index.Range(min, max))
            {
                Debug.Assert(min.le(quote));
                Debug.Assert(quote.le(max));
                n += 1;
            }
            Debug.Assert(n >= 1);
            total += n;
        }
        Console.WriteLine("Elapsed time for  performing " + nRecords + " range query by example searches: " + (DateTime.Now - start));

        start = System.DateTime.Now;
        n = 0;
        foreach (Quote q in index)
        {
            n += 1;
        }
        Debug.Assert(n == nRecords);
        Console.WriteLine("Elapsed time for iterating through " + nRecords + " records: " + (DateTime.Now - start));

        start = System.DateTime.Now;
        n = 0;
//.........这里部分代码省略.........
开发者ID:yan122725529,项目名称:TripRobot.Crawler,代码行数:101,代码来源:TestKDTree.cs


注:本文中的Quote.le方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。