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.

OIBTree.py 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. 'OIBucket', 'OISet', 'OIBTree', 'OITreeSet',
  16. 'union', 'intersection', 'difference',
  17. 'weightedUnion', 'weightedIntersection',
  18. )
  19. from zope.interface import moduleProvides
  20. from .Interfaces import IObjectIntegerBTreeModule
  21. from ._base import Bucket
  22. from ._base import MERGE
  23. from ._base import MERGE_WEIGHT_numeric
  24. from ._base import MERGE_DEFAULT_float
  25. from ._base import Set
  26. from ._base import Tree as BTree
  27. from ._base import TreeSet
  28. from ._base import _TreeIterator
  29. from ._base import difference as _difference
  30. from ._base import intersection as _intersection
  31. from ._base import set_operation as _set_operation
  32. from ._base import to_ob as _to_key
  33. from ._base import to_int as _to_value
  34. from ._base import union as _union
  35. from ._base import weightedIntersection as _weightedIntersection
  36. from ._base import weightedUnion as _weightedUnion
  37. from ._base import _fix_pickle
  38. from ._compat import import_c_extension
  39. _BUCKET_SIZE = 60
  40. _TREE_SIZE = 250
  41. using64bits = True
  42. class OIBucketPy(Bucket):
  43. _to_key = _to_key
  44. _to_value = _to_value
  45. MERGE = MERGE
  46. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  47. MERGE_DEFAULT = MERGE_DEFAULT_float
  48. class OISetPy(Set):
  49. _to_key = _to_key
  50. MERGE = MERGE
  51. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  52. MERGE_DEFAULT = MERGE_DEFAULT_float
  53. class OIBTreePy(BTree):
  54. max_leaf_size = _BUCKET_SIZE
  55. max_internal_size = _TREE_SIZE
  56. _to_key = _to_key
  57. _to_value = _to_value
  58. MERGE = MERGE
  59. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  60. MERGE_DEFAULT = MERGE_DEFAULT_float
  61. class OITreeSetPy(TreeSet):
  62. max_leaf_size = _BUCKET_SIZE
  63. max_internal_size = _TREE_SIZE
  64. _to_key = _to_key
  65. MERGE = MERGE
  66. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  67. MERGE_DEFAULT = MERGE_DEFAULT_float
  68. class OITreeIteratorPy(_TreeIterator):
  69. pass
  70. # Can't declare forward refs, so fix up afterwards:
  71. OIBucketPy._mapping_type = OIBucketPy._bucket_type = OIBucketPy
  72. OIBucketPy._set_type = OISetPy
  73. OISetPy._mapping_type = OIBucketPy
  74. OISetPy._set_type = OISetPy._bucket_type = OISetPy
  75. OIBTreePy._mapping_type = OIBTreePy._bucket_type = OIBucketPy
  76. OIBTreePy._set_type = OISetPy
  77. OITreeSetPy._mapping_type = OIBucketPy
  78. OITreeSetPy._set_type = OITreeSetPy._bucket_type = OISetPy
  79. differencePy = _set_operation(_difference, OISetPy)
  80. unionPy = _set_operation(_union, OISetPy)
  81. intersectionPy = _set_operation(_intersection, OISetPy)
  82. weightedUnionPy = _set_operation(_weightedUnion, OISetPy)
  83. weightedIntersectionPy = _set_operation(_weightedIntersection, OISetPy)
  84. import_c_extension(globals())
  85. _fix_pickle(globals(), __name__)
  86. moduleProvides(IObjectIntegerBTreeModule)