summaryrefslogtreecommitdiff
path: root/utils/testlist.cc
diff options
context:
space:
mode:
authorchatty2000-11-28 14:19:34 +0000
committerchatty2000-11-28 14:19:34 +0000
commit09f57c8dffd9a8ba0983cce13381aef716f43801 (patch)
tree49c5faa7cd1b76eea36169b5ecce09411b2802c2 /utils/testlist.cc
parent2575756ec6f41bd05bf4505ccc0253fad0ed77c4 (diff)
downloadivy-league-09f57c8dffd9a8ba0983cce13381aef716f43801.zip
ivy-league-09f57c8dffd9a8ba0983cce13381aef716f43801.tar.gz
ivy-league-09f57c8dffd9a8ba0983cce13381aef716f43801.tar.bz2
ivy-league-09f57c8dffd9a8ba0983cce13381aef716f43801.tar.xz
*** empty log message ***
Diffstat (limited to 'utils/testlist.cc')
-rw-r--r--utils/testlist.cc76
1 files changed, 76 insertions, 0 deletions
diff --git a/utils/testlist.cc b/utils/testlist.cc
new file mode 100644
index 0000000..076d88e
--- /dev/null
+++ b/utils/testlist.cc
@@ -0,0 +1,76 @@
+#include <stdio.h>
+#include "String.h"
+#include "List.h"
+
+main ()
+{
+#ifdef CPLUS_BUG19
+ CcuList l;
+#else
+ CcuListOf <char> l;
+#endif
+ char c;
+ char s[80];
+ while ((c = getchar ()) != EOF) {
+ switch (c) {
+ case 'a':
+ scanf (" %s", s);
+ l.Append (NewString (s));
+ break;
+ case 'p':
+ scanf (" %s", s);
+ l.Prepend (NewString (s));
+ break;
+ case '+':
+ l.RemoveFirst ();
+ break;
+ case '-':
+ l.RemoveLast ();
+ break;
+ case '\n':
+ continue;
+ case 'i':
+ {
+ int i;
+ scanf (" %d %s", &i, s);
+#ifdef CPLUS_BUG19
+ CcuListIter lj (l);
+#else
+ CcuListIterOf <char> lj (l);
+#endif
+ while ((i-- > 0) && ++lj)
+ ;
+ l.InsertBefore (lj, NewString (s));
+ break;
+ }
+ case 'j':
+ {
+ int i;
+ scanf (" %d %s", &i, s);
+#ifdef CPLUS_BUG19
+ CcuListIter lj (l);
+#else
+ CcuListIterOf <char> lj (l);
+#endif
+ while ((i-- > 0) && ++lj)
+ ;
+ l.InsertAfter (lj, NewString (s));
+ break;
+ }
+ }
+#ifdef CPLUS_BUG19
+ CcuListIter li (l);
+ while (++li) {
+ char* pt = (char*) *li;
+ printf ("%s ", pt);
+ }
+#else
+ CcuListIterOf <char> li (l);
+ while (++li) {
+ char* pt = *li;
+ printf ("%s ", pt);
+ }
+#endif
+ printf ("\n");
+ }
+}