Ejemplo n.º 1
0
        // Pozosta³e elementy nie zmieniaj¹ kolejnoœci
        public bool Remove(int v)
        {
            if (head == null)
            {
                return(false);
            }
            Elem pp = null, p = head;

            while (p != null)
            {
                if (p.key == v)
                {
                    break;
                }
                pp = p;
                p  = p.next;
            }
            if (p == null)
            {
                return(false);
            }
            if (pp == null)
            {
                head = p.next;
            }
            else if (p.next == null)
            {
                pp.next = null;
                tail    = pp;
            }
            else
            {
                pp.next = p.next;
            }
            return(true);  // zmieniæ
        }
Ejemplo n.º 2
0
 public Elem(int k, Elem n = null)
 {
     key  = k;
     next = n;
 }
Ejemplo n.º 3
0
 private static int CountElement(Elem[] el, int begin, int end, Elem element)
 {
     return(-1);
 }
Ejemplo n.º 4
0
        // zwraca dominujacy element (gdy takiego nie ma zwraca null)
        // w parametrze max ustawia liczbe wystapien dominujacego elementu (gdy takiego nie ma ustawia 0)
        // wymagana zlozonosc o(n*log(n))
        static public Elem FindWinnerFast(Elem[] el, out int max)
        {
            Elem t = FindWinnerRec(el, out max, 0, el.Length - 1);

            return(t);
        }
 public Elem(int v, Elem n = null)
 {
     Val = v; Next = n;
 }
Ejemplo n.º 6
0
 public static string Description(this Elem e)
 {
     return(e == null ? "brak" : string.Format("{0,4}", e.ToString()));
 }
Ejemplo n.º 7
0
 public bool Compare(Elem e)
 {
     ++CompareCount;
     return(value == e.value);
 }