summaryrefslogtreecommitdiff
path: root/src/keyword-list.cc
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2003-01-15 13:01:25 +0000
committerBruno Haible <bruno@clisp.org>2003-01-15 13:01:25 +0000
commitc3467c53024650c0a495d30caabad74ecea4f080 (patch)
tree0dfd3df1b3c4747fac443f22abf2eaa4157a4e7d /src/keyword-list.cc
parentc67f999b54f456288561652503e8ad314a671f98 (diff)
downloadgperf-c3467c53024650c0a495d30caabad74ecea4f080.tar.gz
New option --multiple-iterations.
Diffstat (limited to 'src/keyword-list.cc')
-rw-r--r--src/keyword-list.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/keyword-list.cc b/src/keyword-list.cc
index b154a98..8e0983c 100644
--- a/src/keyword-list.cc
+++ b/src/keyword-list.cc
@@ -25,18 +25,60 @@
#include <stddef.h>
+/* -------------------------- Keyword_List class --------------------------- */
+
/* Constructor. */
Keyword_List::Keyword_List (Keyword *car)
: _cdr (NULL), _car (car)
{
}
+/* ------------------------- KeywordExt_List class ------------------------- */
+
/* Unused constructor. */
KeywordExt_List::KeywordExt_List (KeywordExt *car)
: Keyword_List (car)
{
}
+/* ------------------------ Keyword_List functions ------------------------- */
+
+/* Copies a linear list, sharing the list elements. */
+Keyword_List *
+copy_list (Keyword_List *list)
+{
+ Keyword_List *result;
+ Keyword_List **lastp = &result;
+ while (list != NULL)
+ {
+ Keyword_List *new_cons = new Keyword_List (list->first());
+ *lastp = new_cons;
+ lastp = &new_cons->rest();
+ list = list->rest();
+ }
+ *lastp = NULL;
+ return result;
+}
+
+/* Copies a linear list, sharing the list elements. */
+KeywordExt_List *
+copy_list (KeywordExt_List *list)
+{
+ return static_cast<KeywordExt_List *> (copy_list (static_cast<Keyword_List *> (list)));
+}
+
+/* Deletes a linear list, keeping the list elements in memory. */
+void
+delete_list (Keyword_List *list)
+{
+ while (list != NULL)
+ {
+ Keyword_List *rest = list->rest();
+ delete list;
+ list = rest;
+ }
+}
+
#ifndef __OPTIMIZE__