From 09f57c8dffd9a8ba0983cce13381aef716f43801 Mon Sep 17 00:00:00 2001 From: chatty Date: Tue, 28 Nov 2000 14:19:34 +0000 Subject: *** empty log message *** --- utils/testdlist.cc | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 utils/testdlist.cc (limited to 'utils/testdlist.cc') diff --git a/utils/testdlist.cc b/utils/testdlist.cc new file mode 100644 index 0000000..9656883 --- /dev/null +++ b/utils/testdlist.cc @@ -0,0 +1,77 @@ +#include +#include "String.h" +#include "DList.h" + +main () +{ +#ifdef CPLUS_BUG19 + CcuDList l; +#else + CcuDListOf 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 'r': + { + CcuDListIterOf li (l); + li.GotoEnd (); + while (--li) { + char* pt = *li; + printf ("%s ", pt); + } + printf ("\n"); + continue; + } + case 'i': + { + int i; + scanf (" %d %s", &i, s); + CcuDListIterOf lj (l); + while ((i-- > 0) && ++lj) + ; + l.InsertBefore (lj, NewString (s)); + break; + } + case 'j': + { + int i; + scanf (" %d %s", &i, s); + CcuDListIterOf lj (l); + while ((i-- > 0) && ++lj) + ; + l.InsertAfter (lj, NewString (s)); + break; + } + } +#ifdef CPLUS_BUG19 + CcuDListIter li (l); + while (++li) + printf ("%s ", (char*) *li); +#else + CcuDListIterOf li (l); + while (++li) { + char* pt = *li; + printf ("%s ", pt); + } +#endif + printf ("\n"); + } +} -- cgit v1.1