source: abuse/tags/pd/abuse/src/net/mac/tstlist.cc @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 11 years ago
  • Imported original public domain release, for future reference.
File size: 1.3 KB
Line 
1#include "isllist.hpp"
2#include <stdio.h>
3
4typedef isllist<int>::iterator p_int;
5
6main()
7{
8  isllist<int> l1,l2;
9  p_int p,q;
10  int i;
11
12  printf("Adding to first list:\n");
13  l1.insert(5);
14  l1.insert(4);
15  l1.insert(3);
16  l1.insert(2);
17  l1.insert(1);
18
19  printf("List 1: ");
20  for (p = l1.begin(); p!=l1.end(); p++)
21    printf("%d ",*p);
22  printf("\n");
23
24  printf("List 2: ");
25  for (p = l2.begin(); p!=l2.end(); p++)
26    printf("%d ",*p);
27  printf("\n");
28
29  printf("Moving elements!\n");
30
31  l1.move_next(l1.begin_prev(),l2.begin_prev());
32  l1.move_next(l1.begin_prev(),l2.begin_prev());
33  l1.move_next(l1.begin_prev(),l2.begin_prev());
34  l1.move_next(l1.begin_prev(),l2.begin_prev());
35  l1.move_next(l1.begin_prev(),l2.begin_prev());
36 
37  printf("List 1: ");
38  for (p = l1.begin(); p!=l1.end(); p++)
39    printf("%d ",*p);
40  printf("\n");
41
42  printf("List 2: ");
43  for (p = l2.begin(); p!=l2.end(); p++)
44    printf("%d ",*p);
45  printf("\n");
46
47  scanf("%d",&i);
48  printf("%d %s.\n",i,(l2.find(i))? "found" : "not found");
49
50  printf("Erasing\n");
51  l1.erase_all();
52  l2.erase_all();
53
54  printf("List 1: ");
55  for (p = l1.begin(); p!=l1.end(); p++)
56    printf("%d ",*p);
57  printf("\n");
58
59  printf("List 2: ");
60  for (p = l2.begin(); p!=l2.end(); p++)
61    printf("%d ",*p);
62  printf("\n");
63
64}
65
Note: See TracBrowser for help on using the repository browser.