Ejemplo n.º 1
0
        public MyList(krug value)
        {
            var node = new Node(value);

            Head    = node;
            current = Head;
            Tail    = node;
            count++;
        }
Ejemplo n.º 2
0
        public void DrawKrug(krug k, Graphics g)
        {
            Pen pen;

            if (k.color == 1)
            {
                pen = new Pen(Brushes.Blue);
            }
            else
            {
                pen = new Pen(Brushes.Red);
            }
            g.DrawEllipse(pen, k.x - diam / 2, k.y - diam / 2, diam, diam);
        }
Ejemplo n.º 3
0
        public void add(krug value)
        {
            var node = new Node(value);

            if (Head == null)
            {
                Head = node;
            }
            else
            {
                Tail.next = node;
            }
            Tail = node;
            count++;
        }
Ejemplo n.º 4
0
        public void delete(krug value)
        {
            if (Head != null)
            {
                if (Head.data.Equals(value))
                {
                    if (current.next != Tail && current.next != null)
                    {
                        Head = Head.next;
                        count--;

                        current = Head;
                        return;
                    }
                    else
                    {
                        if (current.next == Tail)
                        {
                            Head    = Tail;
                            current = Head;
                            count--;
                            return;
                        }
                        else
                        {
                            Head    = null;
                            Tail    = null;
                            current = null;
                            return;
                        }
                    }
                }

                current = Head.next;
                var pred = Head;

                while (current != null)
                {
                    if (current.data.Equals(value))
                    {
                        if (current == Tail && pred == Head)
                        {
                            Tail         = Head;
                            current      = Head;
                            current.next = null;
                            return;
                        }
                        if (current.next == null)
                        {
                            Tail = pred;
                            count--;
                            current      = Tail;
                            current.next = null;
                            return;
                        }
                        else
                        {
                            pred.next = current.next;
                            count--;

                            current = pred;
                            return;
                        }
                    }
                    pred    = current;
                    current = current.next;
                }
            }
            return;
        }
Ejemplo n.º 5
0
 public Node(krug value)
 {
     data = value;
 }