示例#1
0
        /// <summary>
        /// you can inter a data and get a set with a header and the node that has that data
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static DisjointSetLInkedLIstFormNode <T> Make(T data)
        {
            DisjointSetLInkedLIstFormNode <T> node   = new DisjointSetLInkedLIstFormNode <T>();
            ListHeaderLinkedList <T>          header = new ListHeaderLinkedList <T>();

            node.Data             = data;
            node.Next             = null;
            node.HeaderLinkedList = header;
            header.Head           = node;
            header.Tail           = node;
            header.nodes.AddFirst(node);
            return(node);
        }
示例#2
0
        private static void Join2Part(DisjointSetLInkedLIstFormNode <T> node1, DisjointSetLInkedLIstFormNode <T> node2)
        {
            ListHeaderLinkedList <T> node1Header = node1.HeaderLinkedList;
            ListHeaderLinkedList <T> node2Header = node2.HeaderLinkedList;

            for (int i = 0; i < node1Header.nodes.Count; i++)
            {
                DisjointSetLInkedLIstFormNode <T> temp = node1Header.nodes.First();
                node1Header.nodes.RemoveFirst();
                node2Header.Tail.Next = temp;
                node2Header.Tail      = temp;
                temp.Next             = null;
                temp.HeaderLinkedList = node2Header;
            }
        }