[Zope-Checkins] CVS: Zope2 - SetOpTemplate.c:1.3.2.2
Jim Fulton
jim@digiciool.com
Mon, 12 Mar 2001 11:26:49 -0500 (EST)
Update of /cvs-repository/Zope2/lib/python/BTrees
In directory korak:/tmp/cvs-serv25671
Modified Files:
Tag: Catalog-BTrees-Integration
SetOpTemplate.c
Log Message:
Added support for treating single items as sets for purposes of set
operations. This means that you can::
set = union(set, 42)
--- Updated File SetOpTemplate.c in package Zope2 --
--- SetOpTemplate.c 2001/02/25 00:14:46 1.3.2.1
+++ SetOpTemplate.c 2001/03/12 16:26:49 1.3.2.2
@@ -110,6 +110,23 @@
}
#endif
+#ifdef KEY_CHECK
+static int
+nextKeyAsSet(SetIteration *i)
+{
+ if (i->position >= 0)
+ {
+ if (i->position < 1)
+ {
+ i->position ++;
+ }
+ else
+ i->position = -1;
+ }
+ return 0;
+}
+#endif
+
static int
initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
{
@@ -168,6 +185,19 @@
i->next=nextIntSet;
i->hasValue=0;
+ }
+#endif
+#ifdef KEY_CHECK
+ else if (KEY_CHECK(s))
+ {
+ int copied=1;
+
+ i->set = s;
+ Py_INCREF(s);
+ i->next=nextKeyAsSet;
+ i->hasValue=0;
+ COPY_KEY_FROM_ARG(i->key, s, &copied);
+ UNLESS (copied) return -1;
}
#endif
else