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.

LLBTree.py 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. 'LLBucket', 'LLSet', 'LLBTree', 'LLTreeSet',
  16. 'union', 'intersection', 'difference',
  17. 'weightedUnion', 'weightedIntersection', 'multiunion',
  18. )
  19. from zope.interface import moduleProvides
  20. from .Interfaces import IIntegerIntegerBTreeModule
  21. from ._base import Bucket
  22. from ._base import MERGE
  23. from ._base import MERGE_WEIGHT_numeric
  24. from ._base import MERGE_DEFAULT_int
  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 multiunion as _multiunion
  32. from ._base import set_operation as _set_operation
  33. from ._base import to_long as _to_key
  34. from ._base import to_long as _to_value
  35. from ._base import union as _union
  36. from ._base import weightedIntersection as _weightedIntersection
  37. from ._base import weightedUnion as _weightedUnion
  38. from ._base import _fix_pickle
  39. from ._compat import import_c_extension
  40. _BUCKET_SIZE = 120
  41. _TREE_SIZE = 500
  42. using64bits = True
  43. class LLBucketPy(Bucket):
  44. _to_key = _to_key
  45. _to_value = _to_value
  46. MERGE = MERGE
  47. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  48. MERGE_DEFAULT = MERGE_DEFAULT_int
  49. class LLSetPy(Set):
  50. _to_key = _to_key
  51. MERGE = MERGE
  52. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  53. MERGE_DEFAULT = MERGE_DEFAULT_int
  54. class LLBTreePy(BTree):
  55. max_leaf_size = _BUCKET_SIZE
  56. max_internal_size = _TREE_SIZE
  57. _to_key = _to_key
  58. _to_value = _to_value
  59. MERGE = MERGE
  60. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  61. MERGE_DEFAULT = MERGE_DEFAULT_int
  62. class LLTreeSetPy(TreeSet):
  63. max_leaf_size = _BUCKET_SIZE
  64. max_internal_size = _TREE_SIZE
  65. _to_key = _to_key
  66. MERGE = MERGE
  67. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  68. MERGE_DEFAULT = MERGE_DEFAULT_int
  69. class LLTreeIteratorPy(_TreeIterator):
  70. pass
  71. # Can't declare forward refs, so fix up afterwards:
  72. LLBucketPy._mapping_type = LLBucketPy._bucket_type = LLBucketPy
  73. LLBucketPy._set_type = LLSetPy
  74. LLSetPy._mapping_type = LLBucketPy
  75. LLSetPy._set_type = LLSetPy._bucket_type = LLSetPy
  76. LLBTreePy._mapping_type = LLBTreePy._bucket_type = LLBucketPy
  77. LLBTreePy._set_type = LLSetPy
  78. LLTreeSetPy._mapping_type = LLBucketPy
  79. LLTreeSetPy._set_type = LLTreeSetPy._bucket_type = LLSetPy
  80. differencePy = _set_operation(_difference, LLSetPy)
  81. unionPy = _set_operation(_union, LLSetPy)
  82. intersectionPy = _set_operation(_intersection, LLSetPy)
  83. multiunionPy = _set_operation(_multiunion, LLSetPy)
  84. weightedUnionPy = _set_operation(_weightedUnion, LLSetPy)
  85. weightedIntersectionPy = _set_operation(_weightedIntersection, LLSetPy)
  86. import_c_extension(globals())
  87. _fix_pickle(globals(), __name__)
  88. moduleProvides(IIntegerIntegerBTreeModule)