Пример #1
0
        private static void Main(string[] args)
        {
            RList l = new RList(1);

            l.Insert(5);
            l.Insert(2);
            l.Insert(3);
            l.Insert(4);
            l.ReversePrintList();
            l.Sort();
            l.ReversePrintList();
        }
Пример #2
0
        public static RList operator +(RList l1, RList l2)
        {
            RList res = new RList();

            Node node = l1.Root;

            while (node != null)
            {
                res.Insert(node.Data);
                node = node.Next;
            }

            node = l2.Root;
            while (node != null)
            {
                res.Insert(node.Data);
                node = node.Next;
            }

            return(res);
        }
Пример #3
0
        public static RList operator -(RList l1, RList l2)
        {
            RList res = new RList();

            Node node = l1.Root;

            while (node != null)
            {
                res.Insert(node.Data);
                node = node.Next;
            }

            node = l2.Root;
            while (node != null)
            {
                if (res.Search(node.Data) >= 0)
                {
                    res.DeleteNode(res.Search(node.Data) + 1);
                }
                node = node.Next;
            }
            return(res);
        }