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


C# Car.Deallocate方法代码示例

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


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

示例1: Main

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

        Catalogue root = (Catalogue) db.GetRoot();
        if (root == null)
        {
            root = new Catalogue();
            root.optionIndex = db.CreateBitIndex();
            root.modelIndex = db.CreateFieldIndex(typeof(Car), "model", true);
            db.SetRoot(root);
        }
        BitIndex index = root.optionIndex;
        long start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
        long rnd = 1999;
        int i, n;

        int selectedOptions = Car.TURBO | Car.DISEL | Car.FWD | Car.ABS | Car.EBD | Car.ESP | Car.AIR_COND | Car.HATCHBACK | Car.CLASS_C;
        int unselectedOptions = Car.AUTOMATIC;

        for (i = 0, n = 0; i < nRecords; i++)
        {
            rnd = (3141592621L * rnd + 2718281829L) % 1000000007L;
            int options = (int) rnd;
            Car car = new Car();
            car.model = Convert.ToString(rnd);
            car.options = options;
            root.modelIndex.Put(car);
            root.optionIndex.Put(car, options);
            if ((options & selectedOptions) == selectedOptions && (options & unselectedOptions) == 0)
            {
                n += 1;
            }
        }
        Console.Out.WriteLine("Elapsed time for inserting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");

        start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
        IEnumerator iterator = root.optionIndex.GetEnumerator(selectedOptions, unselectedOptions);
        for (i = 0; iterator.MoveNext(); i++)
        {
            Car car = (Car) iterator.Current;
            Assert.That((car.options & selectedOptions) == selectedOptions);
            Assert.That((car.options & unselectedOptions) == 0);
        }

        Console.Out.WriteLine("Number of selected cars: " + i);
        Assert.That(i == n);
        Console.Out.WriteLine("Elapsed time for bit search through " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
        start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
        foreach (var o in root.modelIndex)
        {
            Car car = (Car) o;
            root.optionIndex.Remove(car);
            car.Deallocate();
        }
        root.optionIndex.Clear();
        Console.Out.WriteLine("Elapsed time for removing " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");

        db.Close();
    }
开发者ID:kjk,项目名称:tenderbase,代码行数:61,代码来源:TestBit.cs

示例2: Run

        public void Run(TestConfig config)
        {
            int count = config.Count;
            var res = new TestBitResult();
            config.Result = res;

            DateTime start = DateTime.Now;
            IDatabase db = config.GetDatabase();

            Catalogue root = (Catalogue)db.Root;
            Tests.Assert(root == null);
            root = new Catalogue();
            root.optionIndex = db.CreateBitIndex<Car>();
            root.modelIndex = db.CreateFieldIndex<string, Car>("model", IndexType.Unique);
            db.Root = root;

            long rnd = 1999;
            int i, n;

            Options selectedOptions = Options.TURBO | Options.DISEL | Options.FWD | Options.ABS | Options.EBD | Options.ESP | Options.AIR_COND | Options.HATCHBACK | Options.CLASS_C;
            Options unselectedOptions = Options.AUTOMATIC;

            for (i = 0, n = 0; i < count; i++)
            {
                Options options = (Options)rnd;
                Car car = new Car();
                car.hps = i;
                car.maxSpeed = car.hps * 10;
                car.timeTo100 = 12;
                car.vendor = "Toyota";
                car.specification = "unknown";
                car.model = Convert.ToString(rnd);
                car.options = options;
                root.modelIndex.Put(car);
                root.optionIndex[car] = (int)options;
                if ((options & selectedOptions) == selectedOptions && (options & unselectedOptions) == 0)
                {
                    n += 1;
                }
                rnd = (3141592621L * rnd + 2718281829L) % 1000000007L;
            }
            res.InsertTime = DateTime.Now - start;

            start = DateTime.Now;
            i = 0;
            foreach (Car car in root.optionIndex.Select((int)selectedOptions, (int)unselectedOptions))
            {
                Tests.Assert((car.options & selectedOptions) == selectedOptions);
                Tests.Assert((car.options & unselectedOptions) == 0);
                i += 1;
            }
            Tests.Assert(i == n);
            res.SearchTime = DateTime.Now - start;

            start = DateTime.Now;
            i = 0;
            foreach (Car car in root.modelIndex)
            {
                root.optionIndex.Remove(car);
                car.Deallocate();
                i += 1;
            }
            Tests.Assert(i == count);
            root.optionIndex.Clear();
            res.RemoveTime = DateTime.Now - start;
            db.Close();
        }
开发者ID:kjk,项目名称:volante,代码行数:67,代码来源:TestBit.cs


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