Example #1
0
        public void DoubleXTest(string str, bool expected)
        {
            Loops lw     = new Loops();
            bool  result = lw.DoubleX(str);

            Assert.AreEqual(expected, result);
        }
Example #2
0
        public void Pattern51test(int [] numbers, bool expected)
        {
            Loops lw     = new Loops();
            bool  result = lw.Pattern51(numbers);

            Assert.AreEqual(expected, result);
        }
Example #3
0
        public void FrontTimesTest(string str, int n, string expected)
        {
            Loops  lw     = new Loops();
            string result = lw.FrontTimes(str, n);

            Assert.AreEqual(expected, result);
        }
Example #4
0
        public void Array667Test(int[] numbers, int expected)
        {
            Loops lw     = new Loops();
            int   result = lw.Array667(numbers);

            Assert.AreEqual(expected, result);
        }
Example #5
0
        public void NoTriplesTest(int [] numbers, bool expected)
        {
            Loops lw     = new Loops();
            bool  result = lw.NoTriples(numbers);

            Assert.AreEqual(expected, result);
        }
Example #6
0
        public void DoNotYakTest(string str, string expected)
        {
            Loops  lw     = new Loops();
            string result = lw.DoNotYak(str);

            Assert.AreEqual(expected, result);
        }
Example #7
0
        public void AltPairsTest(string str, string expected)
        {
            Loops  lw     = new Loops();
            string result = lw.AltPairs(str);

            Assert.AreEqual(expected, result);
        }
Example #8
0
        public void SubStringMatchTest(string a, string b, int expected)
        {
            Loops lw     = new Loops();
            int   result = lw.SubStringMatch(a, b);

            Assert.AreEqual(expected, result);
        }
Example #9
0
        public void EveryOtherTest(string str, string expected)
        {
            Loops  lw     = new Loops();
            string result = lw.EveryOther(str);

            Assert.AreEqual(expected, result);
        }
Example #10
0
        public void StringSplosionTest(string str, string expected)
        {
            Loops  lw     = new Loops();
            string result = lw.StringSplosion(str);

            Assert.AreEqual(expected, result);
        }
Example #11
0
 static void Main(string[] args)
 {
     // Loops.Ex1();
     // Loops.Ex2();
     // Loops.Ex3();
     Loops.Ex4();
 }
Example #12
0
        public void AddEntity(IEntityG entity)
        {
            switch (entity.Type)
            {
            case EntityGType.line:
                Lines.Add((LineG)entity);
                break;

            case EntityGType.arc:
                Circles.Add((CircleG)entity);
                break;

            case EntityGType.loop:
                Loops.Add((LoopG)entity);
                break;

            case EntityGType.surf:
                Surfaces.Add((PlaneSurface)entity);
                break;

            case EntityGType.phsurf:
                PhySurfaces.Add((PhysicalSurface)entity);
                break;

            case EntityGType.phcurve:
                PhyCurves.Add((PhysicalCurve)entity);
                break;

            case EntityGType.point:
                Points.Add((PointG)entity);
                break;
            }
        }
Example #13
0
        protected override void LoadChunk(IntPtr ptr, string type, uint size)
        {
            switch (type)
            {
            case "DLID":
            case "GUID":
                break;

            case "fmt ":
                Format = Marshal.PtrToStructure <CK_FMT>(ptr);
                break;

            case "data":
                Addr = (uint)ptr.ToInt64();
                Size = size;
                break;

            case "wsmp":
                Sampler = Marshal.PtrToStructure <CK_WSMP>(ptr);
                ptr    += Marshal.SizeOf <CK_WSMP>();
                for (uint i = 0; i < Sampler.loopCount; ++i)
                {
                    Loops.Add(Marshal.PtrToStructure <WAVE_LOOP>(ptr));
                    ptr += Marshal.SizeOf <WAVE_LOOP>();
                }
                HasLoop = 0 < Sampler.loopCount;
                break;

            default:
                throw new Exception("[WAVE]Unknown ChunkType");
            }
        }
Example #14
0
        void EmitIterationStatement(CodeIterationStatement Iterate)
        {
            Depth++;
            Debug("Emitting iteration statement");

            // Used for break and continue later on
            var Meta = new LoopMetadata {
                Begin = Generator.DefineLabel(),
                End   = Generator.DefineLabel(),
            };

            Loops.Push(Meta);

            EmitStatement(Iterate.InitStatement, false);

            // The beginning of our loop: check the limit
            Generator.MarkLabel(Meta.Begin);

            EmitExpression(Iterate.TestExpression, false);
            Generator.Emit(OpCodes.Brfalse, Meta.End);

            // Emit the actual statements within
            EmitStatementCollection(Iterate.Statements);

            // Increase the counter by one
            EmitStatement(Iterate.IncrementStatement, false);

            // Start all over again
            Generator.Emit(OpCodes.Br, Meta.Begin);
            Generator.MarkLabel(Meta.End);

            Loops.Pop();
            Depth--;
        }
Example #15
0
        protected override void LoadChunk(IntPtr ptr, string type, uint size)
        {
            switch (type)
            {
            case "rgnh":
                Header = Marshal.PtrToStructure <CK_RGNH>(ptr);
                break;

            case "wlnk":
                WaveLink = Marshal.PtrToStructure <CK_WLNK>(ptr);
                break;

            case "wsmp":
                Sampler = Marshal.PtrToStructure <CK_WSMP>(ptr);
                ptr    += Marshal.SizeOf <CK_WSMP>();
                for (uint i = 0; i < Sampler.loopCount; ++i)
                {
                    Loops.Add(Marshal.PtrToStructure <WAVE_LOOP>(ptr));
                    ptr += Marshal.SizeOf <WAVE_LOOP>();
                }
                HasSampler = true;
                HasLoop    = 0 < Sampler.loopCount;
                break;

            default:
                throw new Exception("[RGN_]Unknown ChunkType");
            }
        }
Example #16
0
 static void Main(string[] args)
 {
     int[] i = new int[] { 1, 2, 3, 4 };
     Loops.ForCombo <int>(2, i, (int[] a) => { Console.Write(a[0] + " " + a[1] + "   "); }, false, false);
     Console.WriteLine();
     Loops.ForCombo <int>(2, i, (int[] a) => { Console.Write(a[0] + " " + a[1] + "   "); }, true, false);
     Console.WriteLine();
     Loops.ForCombo <int>(2, i, (int[] a) => { Console.Write(a[0] + " " + a[1] + "   "); }, false, true);
     Console.WriteLine();
     Loops.ForCombo <int>(2, i, (int[] a) => { Console.Write(a[0] + " " + a[1] + "   "); }, true, true);
     Console.WriteLine("6! test, should be 6x5x4x3x2x1=720: " + ComboMath.Factorial(6));
     Console.WriteLine("Simple combination calculator test: chose 2 out of 4, should be 6: " + ComboMath.NumberOfSimpleCombinations(2, 4));
     Console.WriteLine("Combination with replacement calculator test: chose 2 out of 4, should be 10: " + ComboMath.NumberOfCombinationsWithReplacement(2, 4));
     Console.WriteLine("Simple permutation calculator test: chose 2 out of 4, should be 12: " + ComboMath.NumberOfSimplePermutations(2, 4));
     Console.WriteLine("Permutation with replacement calculator test: chose 2 out of 4, should be 16: " + ComboMath.NumberOfPermutationsWithReplacement(2, 4));
     int[][] ii = ComboMath.GetSimpleCombinations <int>(i, 2);
     foreach (int[] ia in ii)
     {
         foreach (int ie in ia)
         {
             Console.Write(ie);
         }
         Console.WriteLine();
     }
     int[] b = Loops.Append <int>(new int[] { 1, 2, 3, 4, 5 }, 12);
     foreach (int ia in b)
     {
         Console.Write(ia);
     }
 }
Example #17
0
        private List <List <string> > filterPaths(List <List <string> > strPaths)
        {
            List <List <string> > strFilteredPaths = new List <List <string> >();

            foreach (var checkingPath in strPaths)
            {
                int  clearPath = 0; //0: clean, 1: loop start; 2 dirtyPath
                bool firstNode = true;
                foreach (var nodeKey in checkingPath)
                {
                    if (firstNode)
                    {
                        firstNode = false;
                        continue;
                    }

                    //check there's no path starting from this Node key
                    //that should remove loops
                    int index = 0;
                    foreach (var lookupPath in strPaths)
                    {
                        if (lookupPath.Count > 1 && lookupPath[1].Equals(nodeKey))
                        {
                            //this is a loop, skip
                            if (lookupPath.Count < checkingPath.Count)
                            {
                                if (index == 0)
                                {
                                    clearPath = 1;
                                }
                                else
                                {
                                    clearPath = 2;
                                }
                                break;
                            }
                        }
                        index++;
                    }

                    if (clearPath != 0)
                    {
                        break;
                    }
                }

                if (clearPath == 1)
                {
                    //HACK: add to loops Dict
                    Loops.Add(checkingPath, "");
                    strFilteredPaths.Add(checkingPath);
                }
                else if (clearPath == 0)
                {
                    strFilteredPaths.Add(checkingPath);
                }
            }

            return(strFilteredPaths);
        }
Example #18
0
        public void Array123Test(int[] numbers, bool expected)
        {
            Loops lw     = new Loops();
            bool  result = lw.Array123(numbers);

            Assert.AreEqual(expected, result);
        }
Example #19
0
        public void Count9Test(int[] numbers, int expected)
        {
            Loops lw     = new Loops();
            int   result = lw.Count9(numbers);

            Assert.AreEqual(expected, result);
        }
Example #20
0
        public void CountLast2Test(string str, int expected)
        {
            Loops lw     = new Loops();
            int   result = lw.CountLast2(str);

            Assert.AreEqual(expected, result);
        }
Example #21
0
 private static void LoopUnrolling()
 {
     Console.WriteLine(".NET-Specific Pitfalls");
     Console.WriteLine("Loop Unrolling");
     Loops.LoopUnrolling();
     Loops.LoopAvoidUnrolling(1000000001, 1000000002);
     Console.WriteLine("Advice: use variables instead of constants in loops");
 }
Example #22
0
    public void RemoveUnfinishedLoopPanel()
    {
        GameManager.instance.LoopMode = false;
        Loops.RemoveAt(Loops.Count - 1);
        LoopButton loopButton = mainPanel.GetComponent <MainPanel>().CommandsPanel.LoopButton.GetComponent <LoopButton>();

        loopButton.DisableLoopMode();
    }
Example #23
0
 void Awake()
 {
     if (!AppStart.isInit)
     {
         Loops.Init();
         AppStart.Start();
     }
 }
Example #24
0
 public void SaveLoop <T>(T loop)
 {
     if (!Loops.ContainsKey(typeof(T)))
     {
         Loops[typeof(T)] = new List <object>();
     }
     Loops[typeof(T)].Add(loop);
 }
Example #25
0
 Timer(float delay, TimerHandler handler = null, Loops loop = Loops.Once)
 {
     interval = delay;
     method   = handler;
     loops    = loop;
     tick     = interval;
     index    = indexs++;
 }
Example #26
0
 private static void DeadCodeElimination()
 {
     Console.WriteLine(".NET-Specific Pitfalls");
     Console.WriteLine("Dead Code Elimination");
     Console.WriteLine(@"If you don’t use the results of your code, the code can be completely removed.");
     Loops.LoopDeadCodeElimination();
     Loops.LoopDeadCodeEliminationCollectResult();
     Console.WriteLine("Advice: always use results of your calculations");
 }
Example #27
0
        static void Main(string[] args)
        {
            LearnToDebug();
            Loops.Looping();
            if_else_statements.IfElse();

            //--------Delay--------
            Console.ReadKey();
        }
Example #28
0
        internal void OnDeserialized(StreamingContext context)
        {
            Edges.ForEach(e => e.Brep = this);
            Loops.ForEach(l => l.Brep = this);
            Trims.ForEach(t => t.Brep = this);
            Faces.ForEach(f => f.Brep = this);

            //TODO: all the data props to the real props
        }
        public void SumOfElementsUsingForLoopTest()
        {
            TimeSpan totalTime = new TimeSpan();

            for (int i = 0; i < iterations; i++)
            {
                totalTime += Method.Time(() => Loops.SumOfArrayUsingForLoop(sampleArray));
            }
            Console.WriteLine(string.Format("{0}: {1}", MethodBase.GetCurrentMethod(), totalTime.TotalMilliseconds));
        }
Example #30
0
    public static void Main()
    {
        Loops lp = new Loops();

        //lp.WHILE();
        //lp.DOWHILE();
        //lp.coffeBill();
        //lp.FOR();
        lp.FOREACH();
    }