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
3a16bcfa
Commit
3a16bcfa
authored
May 31, 2002
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
_BTree_get(): Added docs, and minor code cleanups.
parent
9e2d8d99
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
src/BTrees/BTreeTemplate.c
src/BTrees/BTreeTemplate.c
+23
-7
No files found.
src/BTrees/BTreeTemplate.c
View file @
3a16bcfa
...
...
@@ -12,18 +12,34 @@
****************************************************************************/
#define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.3
3 2002/05/31 20:01:16
tim_one Exp $\n"
#define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.3
4 2002/05/31 20:42:37
tim_one Exp $\n"
/*
** _BTree_get
**
** Search a BTree.
**
** Arguments
** self a pointer to a BTree
** keyarg the key to search for, as a Python object
** has_key true/false; when false, try to return the associated
** value; when true, return a boolean
** Return
** When has_key false:
** If key exists, its associated value.
** If key doesn't exist, NULL and KeyError is set.
** When has_key true:
** A Python int is returned in any case.
** If key exists, the depth of the bucket in which it was found.
** If key doesn't exist, 0.
*/
static
PyObject
*
_BTree_get
(
BTree
*
self
,
PyObject
*
keyarg
,
int
has_key
)
{
int
min
,
copied
=
1
;
PyObject
*
r
=
NULL
;
KEY_TYPE
key
;
int
min
;
/* index of child to search */
PyObject
*
r
=
NULL
;
/* result object */
int
copied
=
1
;
COPY_KEY_FROM_ARG
(
key
,
keyarg
,
copied
);
UNLESS
(
copied
)
return
NULL
;
...
...
@@ -34,7 +50,7 @@ _BTree_get(BTree *self, PyObject *keyarg, int has_key)
if
(
self
->
len
)
{
if
(
SameType_Check
(
self
,
self
->
data
[
min
].
child
))
r
=
_BTree_get
(
BTREE
(
self
->
data
[
min
].
child
),
keyarg
,
r
=
_BTree_get
(
BTREE
(
self
->
data
[
min
].
child
),
keyarg
,
has_key
?
has_key
+
1
:
0
);
else
r
=
_bucket_get
(
BUCKET
(
self
->
data
[
min
].
child
),
keyarg
,
...
...
@@ -42,10 +58,10 @@ _BTree_get(BTree *self, PyObject *keyarg, int has_key)
}
else
{
/* No data */
UNLESS
(
has_key
)
PyErr_SetObject
(
PyExc_KeyError
,
keyarg
);
else
if
(
has_key
)
r
=
PyInt_FromLong
(
0
);
else
PyErr_SetObject
(
PyExc_KeyError
,
keyarg
);
}
Error:
...
...
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