diff options
Diffstat (limited to 'src/backend/nodes/list.c')
-rw-r--r-- | src/backend/nodes/list.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/backend/nodes/list.c b/src/backend/nodes/list.c index 063212e25fa..6dc6001a0f2 100644 --- a/src/backend/nodes/list.c +++ b/src/backend/nodes/list.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.41 2002/06/20 20:29:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.42 2002/11/24 21:52:13 tgl Exp $ * * NOTES * XXX a few of the following functions are duplicated to handle @@ -373,6 +373,46 @@ set_unioni(List *l1, List *l2) } /* + * Generate the intersection of two lists, + * ie, all members of both l1 and l2. + * + * NOTE: if there are duplicates in l1 they will still be duplicate in the + * result; but duplicates in l2 are discarded. + * + * The result is a fresh List, but it points to the same member nodes + * as were in the inputs. + */ +#ifdef NOT_USED +List * +set_intersect(List *l1, List *l2) +{ + List *retval = NIL; + List *i; + + foreach(i, l1) + { + if (member(lfirst(i), l2)) + retval = lappend(retval, lfirst(i)); + } + return retval; +} +#endif + +List * +set_intersecti(List *l1, List *l2) +{ + List *retval = NIL; + List *i; + + foreach(i, l1) + { + if (intMember(lfirsti(i), l2)) + retval = lappendi(retval, lfirsti(i)); + } + return retval; +} + +/* * member() * nondestructive, returns t iff l1 is a member of the list l2 */ |