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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
06cf5863
Commit
06cf5863
authored
Feb 17, 2001
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First-cut interface definitions for the BTree stuff.
parent
018047e5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
177 additions
and
0 deletions
+177
-0
src/BTrees/Interfaces.py
src/BTrees/Interfaces.py
+177
-0
No files found.
src/BTrees/Interfaces.py
0 → 100644
View file @
06cf5863
import
OOBTree
,
Interface
class
ICollection
(
Interface
.
Base
):
def
clear
():
"""Remove all of the items from the collection"""
def
__nonzero__
():
"""Check if the collection is non-empty.
Return a true value if the collection is non-empty and a
false otherwise.
"""
class
ISized
(
ICollection
):
def
__len__
():
"""Return the number of items in the set"""
class
IReadSequence
(
Interface
.
Base
):
def
__getitem__
(
index
):
"""Return an item for a given index."""
def
__getslice__
(
index1
,
index2
):
"""Return a subsequence from the original sequence
Such that the subsequence includes the items from index1 up
to, but not including, index2.
"""
class
IKeyed
(
ICollection
):
def
has_key
(
key
):
"""Check whether the object has an item with the given key"""
def
keys
(
min
=
None
,
max
=
None
):
"""Return an IReadSequence containing the keys in the collection
The type of the IReadSequence is not specified. It could be a
list or a tuple or some other type.
If a min is specified, then output is constrained to
items having keys greater than or equal to the given min.
A min value of None is ignored.
If a max is specified, then output is constrained to
items having keys less than or equal to the given min.
A max value of None is ignored.
"""
def
maxKey
(
key
=
None
):
"""Return the maximum key
If a key argument if provided, return the largest key that is
less than or equal to the argument.
"""
def
minKey
(
key
=
None
):
"""Return the minimum key
If a key argument if provided, return the smallest key that is
greater than or equal to the argument.
"""
class
ISetMutable
(
IKeyed
):
def
insert
(
key
):
"""Add the key (value) to the set.
If the key was already in the set, return 0, otherwise return 1.
"""
def
remove
(
key
):
"""Remove the key from the set."""
class
IKeySequence
(
IKeyed
,
ISized
):
def
__getitem__
(
index
):
"""Return the key in the given index position
This allows iteration with for loops and use in functions,
like map and list, that read sequences.
"""
class
ISet
(
IKeySequence
,
ISetMutable
):
pass
class
ITreeSet
(
IKeyed
,
ISetMutable
):
pass
class
IDictionaryIsh
(
IKeyed
,
ISized
):
def
__getitem__
(
key
):
"""Get the value for the given key
Raise a key error if the key if not in the collection.
"""
def
get
(
key
,
default
=
None
):
"""Get the value for the given key
Raise a key error if the key if not in the collection and no
default is specified.
Return the default if specified and the key is not in the
collection.
"""
def
__setitem__
(
key
,
value
):
"""Set the value for the given key"""
def
__delitem__
(
key
):
"""delete the value for the given key
Raise a key error if the key if not in the collection."""
def
values
(
min
=
None
,
max
=
None
):
"""Return a IReadSequence containing the values in the collection
The type of the IReadSequence is not specified. It could be a
list or a tuple or some other type.
If a min is specified, then output is constrained to
items having keys greater than or equal to the given min.
A min value of None is ignored.
If a max is specified, then output is constrained to
items having keys less than or equal to the given min.
A max value of None is ignored.
"""
def
items
(
min
=
None
,
max
=
None
):
"""Return a IReadSequence containing the items in the collection
An item is a key-value tuple.
The type of the IReadSequence is not specified. It could be a
list or a tuple or some other type.
If a min is specified, then output is constrained to
items having keys greater than or equal to the given min.
A min value of None is ignored.
If a max is specified, then output is constrained to
items having keys less than or equal to the given min.
A max value of None is ignored.
"""
class
IBTree
(
IDictionaryIsh
):
def
insert
(
key
,
value
):
"""Insert a key and value into the colelction.
If the key was already in the collection, then there is no
change and 0 is returned.
If the key was not already in the collection, then the item is
added and 1 is returned.
This method is here to allow one to generate random keys and
to insert and test whether the key was there in one operation.
A standard idiom for generating new keys will be::
key=generate_key()
while not t.insert(key, value):
key=generate_key()
"""
Interface
.
assertTypeImplements
(
OOBTree
.
OOSet
,
ISet
)
Interface
.
assertTypeImplements
(
OOBTree
.
OOTreeSet
,
ITreeSet
)
Interface
.
assertTypeImplements
(
OOBTree
.
OOBucket
,
IDictionaryIsh
)
Interface
.
assertTypeImplements
(
OOBTree
.
OOBTree
,
IBTree
)
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