Реализация линейной структуры данных и оценка эффективности работы со структурой в зависимости от размерности структуры, страница 3

                                       cntInsert+=4;

                                       return;

                                       }

                    do

                                       {

                                       if (*e->elem < *cur->elem)          

                                                                                                  {

                                                                                                  if (cur == first)//вставлять первым

                                                                                                                      {

                                                                                                                      e->next=first;

                                                                                                                      e->prev=last;

                                                                                                                      last->next=e;

                                                                                                                      first->prev=e;

                                                                                                                      first=e;

                                                                                                                      cnt++;

                                                                                                                      cntInsert+=6;

                                                                                                                      return;

                                                                                                                      }

                                                                                                  e->next = cur;

                                                                                                  e->prev = cur->prev;

                                                                                                  cur->prev->next = e;

                                                                                                  cur->prev = e;

                                                                                                  cnt++;

                                                                                                  cntInsert+=4;

                                                                                                  return;

                                                                                                  }

                                       cur=cur->next;

                                       cntInsert++;

                                       }

                    while (cur != first);

                    //иначе в конец

                    last->next = e;

                    e->next = first;

                    first->prev= e;

                    e->prev = last;

                    last=e;

                    cnt++;

                    cntInsert+=5;

}

//----------------------------------------------------

template <class T>

int List<T>::Delete(int n)

{

                    Elem <T> *cur = first, *tmp;

                    cntDelete++;

                    int c=n;

                    if (c == 0)

                                       {

                                       tmp=first;

                                       first=first->next;

                                       last->next=first;

                                       first->prev=last;

                                       delete tmp;

                                       cnt--;

                                       cntDelete+=6;