Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
33443390
Commit
33443390
authored
Jun 03, 2002
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nextKeyAsSet(): Simplified the code. Added a new test to exercise it.
parent
199bf595
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
src/BTrees/SetOpTemplate.c
src/BTrees/SetOpTemplate.c
+2
-13
src/BTrees/tests/testSetOps.py
src/BTrees/tests/testSetOps.py
+13
-0
No files found.
src/BTrees/SetOpTemplate.c
View file @
33443390
...
...
@@ -16,7 +16,7 @@
Set operations
****************************************************************************/
#define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.1
8 2002/06/03 17:21:55
tim_one Exp $\n"
#define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.1
9 2002/06/03 17:45:08
tim_one Exp $\n"
#ifdef INTSET_H
static
int
...
...
@@ -49,18 +49,7 @@ nextIntSet(SetIteration *i)
static
int
nextKeyAsSet
(
SetIteration
*
i
)
{
/* XXX Looks like this block could be replaced by
* XXX i->position = i->position == 0 ? 1 : -1;
*/
if
(
i
->
position
>=
0
)
{
if
(
i
->
position
<
1
)
{
i
->
position
++
;
}
else
i
->
position
=
-
1
;
}
i
->
position
=
i
->
position
==
0
?
1
:
-
1
;
return
0
;
}
#endif
...
...
src/BTrees/tests/testSetOps.py
View file @
33443390
...
...
@@ -69,6 +69,19 @@ class TestMultiUnion(TestCase):
self
.
assertEqual
(
len
(
output
),
N
*
4
)
self
.
assertEqual
(
list
(
output
),
range
(
-
N
,
3
*
N
))
def
testFunkyKeyIteration
(
self
):
# The internal set iteration protocol allows "iterating over" a
# a single key as if it were a set.
N
=
100
slow
=
IISet
()
for
i
in
range
(
N
):
slow
=
union
(
slow
,
IISet
([
i
]))
fast
=
multiunion
(
range
(
N
))
# acts like N distinct singleton sets
self
.
assertEqual
(
len
(
slow
),
N
)
self
.
assertEqual
(
len
(
fast
),
N
)
self
.
assertEqual
(
list
(
slow
.
keys
()),
list
(
fast
.
keys
()))
self
.
assertEqual
(
list
(
fast
.
keys
()),
range
(
N
))
def
test_suite
():
return
makeSuite
(
TestMultiUnion
,
'test'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment