Пример #1
0
int main()
{
    CMyList<int> lst;
//     
//     POSTION pos1 = lst.AddTail(10);
// 
//     lst.AddTail(7);
//     lst.AddTail(2);
//     POSTION pos2 = lst.AddTail(0);
//     
//     POSTION start = lst.Insert(pos1, 100);
//     lst.Insert(pos2, 20);
//     
//     lst.RemoveAt(pos1);
//     
//     lst.RemoveAt(lst.Find(20));
//     POSTION end = lst.AddTail(112233);
//     lst.RemoveAt(start);
//     lst.RemoveAt(end);


    POSTION pos4 = lst.AddTail(123);
    POSTION pos5 = lst.AddTail(456);
    POSTION pos6 = lst.AddTail(789);

    lst.ChangeNode(pos4, pos5);
    lst.ChangeNode(pos5, pos6);
    lst.ChangeNode(pos4, pos6);

    


    return 0;
}
Пример #2
0
int main(int argc, char* argv[])
{
  CMyList list;
  for (int i = 1; i < 2; i++)
     list.AddTail(i);
  list.RemoveAt(0);

  printf("%d:", list.Length());
  CNode *pNode = list.GetHead();
  while(pNode != NULL)
  {
    printf("%d ", pNode->m_Elem);
    pNode = pNode->m_pNext;
  }
  printf("\r\n");
  pNode = list.GetTail();
  while(pNode != NULL)
  {
    printf("%d ", pNode->m_Elem);
    pNode = pNode->m_pPrev;
  }
  printf("\r\n");
	return 0;
}