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


C# Bag.GetSize方法代码示例

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


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

示例1: TestItvVsCh

        public void TestItvVsCh()
        {
            // HC mechanism
            var gen = new Gerador();
            var dado = new Dice();
            var saco = new Bag<CStamp>();

            var seed = new CStamp();
            seed.Seed(gen.Seed());
            saco.Push(seed);

            // ITC mechanism
            var bag = new Bag<Stamp>();

            var seedb = new Stamp();
            bag.Push(seedb);

            var forks = 0;
            var joins = 0;
            var events = 0;

            int i;
            var counter = 0;
            for (i = 0;
                 i < 1500;
                 i++)
            {
                Debug.WriteLine(i + 1 + ": bugs->" + counter);
                var tipo = dado.Iroll(1, 100);

                if (tipo <= 34
                    || saco.GetSize() == 1)
                {
                    // fork
                    Debug.WriteLine("Fork __________________________");
                    forks++;
                    var ind = saco.GetValidIndice();

                    // mecanismo hc
                    var outStamp = saco.PopInd(ind);
                    CStamp novo = outStamp.Fork();

                    saco.Push(outStamp);
                    saco.Push(novo);

                    // mecanismo itc in place
                    var sout = bag.PopInd(ind);
                    var sin = sout.Fork();

                    bag.Push(sout);
                    bag.Push(sin);

            //				// mecanismo itc funcional
            //				Stamp outb = (Stamp) bag.popInd(ind);
            //				Stamp[] p = Stamp.fork(outb);
            //				Stamp in1 = p[0];
            //				Stamp in2 = p[1];
            //
            //				bag.push(in1);
            //				bag.push(in2);
                }
                else if (tipo <= 66)
                {
                    // join
                    Debug.WriteLine("Join __________________________");
                    joins++;
                    var inda = saco.GetValidIndice();

                    var outa = saco.PopInd(inda);
                    var souta = bag.PopInd(inda);

                    var indb = saco.GetValidIndice();

                    var outb = saco.PopInd(indb);
                    var soutb = bag.PopInd(indb);

                    var novo = new CStamp();
                    novo.Join(outa, outb);
                    saco.Push(novo);

            //				Stamp novob = Stamp.join(souta, soutb);
            //				bag.push(novob);
                    souta.Join(soutb);
                    bag.Push(souta);
                }
                else
                {
                    // event
                    Debug.WriteLine("Event _________________________");
                    events++;
                    var ind = saco.GetValidIndice();

                    var outStamp = saco.PopInd(ind);
                    outStamp.Event(gen.Gera());
                    saco.Push(outStamp);

                    var outb = bag.PopInd(ind);
            //				System.out.println("ANTES:"+outb.toString());
                    outb.MakeEvent();
            //				System.out.println("DPS:"+outb.toString());
//.........这里部分代码省略.........
开发者ID:bradtwurst,项目名称:Interval-Tree-Clocks,代码行数:101,代码来源:TestStamp.cs


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