public static void Main()
        {
            var test = new LinkedList2<string>();

            test.AddFirst("First string");
            test.AddLast("Second string");
            test.AddFirst("Should be before first");
            test.AddLast("Should be after last");

            foreach (var item in test)
            {
                Console.WriteLine(item);
            }

            test.Clear();
            foreach (var item in test)
            {
                Console.WriteLine(item);
            }
        }
Exemplo n.º 2
0
        private void DetectInternal(TimeStep step, bool doX)
        {
            List <Stub>           stubs         = (doX) ? (xStubs) : (yStubs);
            LinkedList2 <Wrapper> currentBodies = new LinkedList2 <Wrapper>();

            for (int index = 0; index < stubs.Count; index++)
            {
                Stub    stub     = stubs[index];
                Wrapper wrapper1 = stub.wrapper;
                if (stub.begin)
                {
                    //set the min and max values
                    if (doX)
                    {
                        wrapper1.SetY();
                    }
                    else
                    {
                        wrapper1.SetX();
                    }

                    Body body1 = wrapper1.body;
                    for (LinkedListNode2 <Wrapper> node = currentBodies.First;
                         node != null;
                         node = node.Next)
                    {
                        Wrapper wrapper2 = node.Value;
                        Body    body2    = wrapper2.body;
                        if (wrapper1.min <= wrapper2.max && //tests the other axis
                            wrapper2.min <= wrapper1.max &&
                            Body.CanCollide(body1, body2))
                        {
                            OnCollision(step, body1, body2);
                        }
                    }
                    if (wrapper1.shouldAddNode)
                    {
                        currentBodies.AddLast(wrapper1.node);
                    }
                }
                else
                {
                    if (wrapper1.shouldAddNode)
                    {
                        currentBodies.Remove(wrapper1.node);
                    }
                }
            }
        }