From 9723fff382b056556f14af20bf07b1f9d3e78e05 Mon Sep 17 00:00:00 2001 From: ccremers Date: Sun, 25 Jul 2004 18:14:21 +0000 Subject: [PATCH] - Added termlistAddNew function to mimic set behaviour. --- src/termlist.c | 15 +++++++++++++++ src/termlist.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/termlist.c b/src/termlist.c index c987ead..ed02bc3 100644 --- a/src/termlist.c +++ b/src/termlist.c @@ -215,6 +215,19 @@ termlistAppend (const Termlist tl, const Term term) return tl; } +//! Add a term only to a list if it wasn't in it before. +/** + * Mimics a basic set type behaviour. + */ +Termlist +termlistAddNew (const Termlist tl, const term t) +{ + if (inTermlist (tl, t)) + return tl; + else + return termlistAdd (tl, t); +} + //! Concatenates two termlists. /** * The last pointer of the first list is made to point to the second list. @@ -762,3 +775,5 @@ int termlistOrder (Termlist tl1, Termlist tl2) else return 1; } + + diff --git a/src/termlist.h b/src/termlist.h index a1958d8..6cde0e8 100644 --- a/src/termlist.h +++ b/src/termlist.h @@ -32,6 +32,7 @@ __inline__ int inTermlist (Termlist tl, const Term term); int isTermlistEqual (Termlist tl1, Termlist tl2); Termlist termlistAdd (Termlist tl, Term term); Termlist termlistAppend (const Termlist tl, const Term term); +Termlist termlistAddNew (const Termlist tl, const term t); Termlist termlistConcat (Termlist tl1, Termlist tl2); Termlist termlistDelTerm (Termlist tl); Termlist termlistConjunct (Termlist tl1, Termlist tl2);