Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IOBTree.py 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2001-2012 Zope Foundation and Contributors.
  4. # All Rights Reserved.
  5. #
  6. # This software is subject to the provisions of the Zope Public License,
  7. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  8. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  9. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  11. # FOR A PARTICULAR PURPOSE
  12. #
  13. ##############################################################################
  14. __all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
  15. 'IOBucket', 'IOSet', 'IOBTree', 'IOTreeSet',
  16. 'union', 'intersection', 'difference', 'multiunion',
  17. )
  18. from zope.interface import moduleProvides
  19. from .Interfaces import IIntegerObjectBTreeModule
  20. from ._base import Bucket
  21. from ._base import MERGE_WEIGHT_default
  22. from ._base import Set
  23. from ._base import Tree as BTree
  24. from ._base import TreeSet
  25. from ._base import _TreeIterator
  26. from ._base import difference as _difference
  27. from ._base import intersection as _intersection
  28. from ._base import multiunion as _multiunion
  29. from ._base import set_operation as _set_operation
  30. from ._base import to_int as _to_key
  31. from ._base import to_ob as _to_value
  32. from ._base import union as _union
  33. from ._base import _fix_pickle
  34. from ._compat import import_c_extension
  35. _BUCKET_SIZE = 60
  36. _TREE_SIZE = 500
  37. using64bits = False
  38. class IOBucketPy(Bucket):
  39. _to_key = _to_key
  40. _to_value = _to_value
  41. MERGE_WEIGHT = MERGE_WEIGHT_default
  42. class IOSetPy(Set):
  43. _to_key = _to_key
  44. class IOBTreePy(BTree):
  45. max_leaf_size = _BUCKET_SIZE
  46. max_internal_size = _TREE_SIZE
  47. _to_key = _to_key
  48. _to_value = _to_value
  49. MERGE_WEIGHT = MERGE_WEIGHT_default
  50. class IOTreeSetPy(TreeSet):
  51. max_leaf_size = _BUCKET_SIZE
  52. max_internal_size = _TREE_SIZE
  53. _to_key = _to_key
  54. class IOTreeIteratorPy(_TreeIterator):
  55. pass
  56. # Can't declare forward refs, so fix up afterwards:
  57. IOBucketPy._mapping_type = IOBucketPy._bucket_type = IOBucketPy
  58. IOBucketPy._set_type = IOSetPy
  59. IOSetPy._mapping_type = IOBucketPy
  60. IOSetPy._set_type = IOSetPy._bucket_type = IOSetPy
  61. IOBTreePy._mapping_type = IOBTreePy._bucket_type = IOBucketPy
  62. IOBTreePy._set_type = IOSetPy
  63. IOTreeSetPy._mapping_type = IOBucketPy
  64. IOTreeSetPy._set_type = IOTreeSetPy._bucket_type = IOSetPy
  65. differencePy = _set_operation(_difference, IOSetPy)
  66. unionPy = _set_operation(_union, IOSetPy)
  67. intersectionPy = _set_operation(_intersection, IOSetPy)
  68. multiunionPy = _set_operation(_multiunion, IOSetPy)
  69. import_c_extension(globals())
  70. _fix_pickle(globals(), __name__)
  71. moduleProvides(IIntegerObjectBTreeModule)