All pastes #904225 Raw Edit

lolz

public text v1 · immutable
·published 2008-02-14 20:13 UTC
rendered paste body
public static void Twelve(Node<int> chain1, Node<int> chain2)
        {
            // Disconnect
            Node<int> pos1 = chain1;
            Node<int> pos2 = chain2;

            while (pos1.GetNextNode() != pos2.GetNextNode() && pos1 != null)
            {
                while (pos2.GetNextNode() != null)
                {
                    if (pos1.GetNextNode() == pos2.GetNextNode())
                        break;
                    pos2 = pos2.GetNextNode();
                }
                if (pos1.GetNextNode() == pos2.GetNextNode())
                    break;
                pos1 = pos1.GetNextNode();
                pos2 = chain2;
            }
            Node<int> pos3 = pos1;
            while (pos3.GetNextNode() != null)
            {
                pos3 = pos3.GetNextNode();
                pos1.SetNext(new Node<int>(pos3.GetInfo()));
                pos1 = pos1.GetNextNode();
            }
            Node<int> pos4 = pos2;
            while (pos4.GetNextNode() != null)
            {
                pos4 = pos4.GetNextNode();
                pos2.SetNext(new Node<int>(pos4.GetInfo()));
                pos2 = pos2.GetNextNode();
            }
        }