symmetric
This commit is contained in:
		
							parent
							
								
									dcad23c818
								
							
						
					
					
						commit
						69297cdac1
					
				| @ -1,10 +1,10 @@ | |||||||
| from typing import Generic, TypeVar | from typing import Generic, TypeVar | ||||||
| 
 | 
 | ||||||
| from rainbowadn.data.collection.collection_interface.collectioninterface import CollectionInterface |  | ||||||
| from rainbowadn.core.hashpoint import HashPoint | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.core.nullability.null import Null | from rainbowadn.core.nullability.null import Null | ||||||
| from rainbowadn.core.nullability.nullablereference import NullableReference | from rainbowadn.core.nullability.nullablereference import NullableReference | ||||||
| from rainbowadn.core.rainbow_factory import RainbowFactory | from rainbowadn.core.rainbow_factory import RainbowFactory | ||||||
|  | from rainbowadn.data.collection.collection_interface.collectioninterface import CollectionInterface | ||||||
| 
 | 
 | ||||||
| __all__ = ('BlockCollectionInterface',) | __all__ = ('BlockCollectionInterface',) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| from typing import Generic, Iterable, TypeVar | from typing import Generic, Iterable, TypeVar | ||||||
| 
 | 
 | ||||||
| from rainbowadn.data.collection.keyed import Keyed |  | ||||||
| from rainbowadn.core.hash_point_format import hash_point_format, tabulate | from rainbowadn.core.hash_point_format import hash_point_format, tabulate | ||||||
| from rainbowadn.core.hashpoint import HashPoint | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.core.hashresolver import HashResolver | from rainbowadn.core.hashresolver import HashResolver | ||||||
| from rainbowadn.core.rainbow_factory import RainbowFactory | from rainbowadn.core.rainbow_factory import RainbowFactory | ||||||
| from rainbowadn.core.resolverorigin import ResolverOrigin | from rainbowadn.core.resolverorigin import ResolverOrigin | ||||||
|  | from rainbowadn.data.collection.keyed import Keyed | ||||||
| 
 | 
 | ||||||
| __all__ = ('KeyMetadata', 'KeyMetadataFactory',) | __all__ = ('KeyMetadata', 'KeyMetadataFactory',) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| from typing import Generic, Iterable, TypeVar | from typing import Generic, Iterable, TypeVar | ||||||
| 
 | 
 | ||||||
| from rainbowadn.data.collection.keyed import Keyed |  | ||||||
| from rainbowadn.core.hashpoint import HashPoint | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.core.hashresolver import HashResolver | from rainbowadn.core.hashresolver import HashResolver | ||||||
| from rainbowadn.core.rainbow_factory import RainbowFactory | from rainbowadn.core.rainbow_factory import RainbowFactory | ||||||
| from rainbowadn.core.resolverorigin import ResolverOrigin | from rainbowadn.core.resolverorigin import ResolverOrigin | ||||||
|  | from rainbowadn.data.collection.keyed import Keyed | ||||||
| 
 | 
 | ||||||
| __all__ = ('KeyValue', 'KeyValueFactory',) | __all__ = ('KeyValue', 'KeyValueFactory',) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ class BinaryTreeAction(Generic[ActiveKeyType, MetaDataType, TreeType, ActionType | |||||||
|         if (split := protocol.split(tree)) is None: |         if (split := protocol.split(tree)) is None: | ||||||
|             return self.on_null(protocol, tree) |             return self.on_null(protocol, tree) | ||||||
|         else: |         else: | ||||||
|             return self.on_split(BinaryTreeCase(protocol, split)) |             return self.on_split(BinaryTreeCase(protocol, split, tree)) | ||||||
| 
 | 
 | ||||||
|     def on_null( |     def on_null( | ||||||
|             self, |             self, | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| import abc | import abc | ||||||
| from typing import Generic, TypeVar | from typing import Generic, TypeVar | ||||||
| 
 | 
 | ||||||
|  | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.data.collection.trees.binary.actions.binarytreeaction import BinaryTreeAction | from rainbowadn.data.collection.trees.binary.actions.binarytreeaction import BinaryTreeAction | ||||||
| from rainbowadn.data.collection.trees.binary.binarytreecase import BinaryTreeCase | from rainbowadn.data.collection.trees.binary.binarytreecase import BinaryTreeCase | ||||||
| from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Equal, Left, Right | from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Equal, Left, Right | ||||||
| from rainbowadn.core.hashpoint import HashPoint |  | ||||||
| 
 | 
 | ||||||
| __all__ = ('CompareAction',) | __all__ = ('CompareAction',) | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										87
									
								
								rainbowadn/data/collection/trees/binary/actions/symmetric.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								rainbowadn/data/collection/trees/binary/actions/symmetric.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,87 @@ | |||||||
|  | from typing import Generic, TypeVar | ||||||
|  | 
 | ||||||
|  | from rainbowadn.core.hashpoint import HashPoint | ||||||
|  | from rainbowadn.data.collection.trees.binary.binarytreecase import BinaryTreeCase | ||||||
|  | from rainbowadn.data.collection.trees.binary.binarytreesplit import BinaryTreeSplit | ||||||
|  | 
 | ||||||
|  | __all__ = ('Symmetric', 'InnerOuter', 'OuterInner',) | ||||||
|  | 
 | ||||||
|  | TreeType = TypeVar('TreeType') | ||||||
|  | ActiveKeyType = TypeVar('ActiveKeyType') | ||||||
|  | MetaDataType = TypeVar('MetaDataType') | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class Symmetric( | ||||||
|  |     Generic[ActiveKeyType, MetaDataType, TreeType] | ||||||
|  | ): | ||||||
|  |     def __init__( | ||||||
|  |             self, | ||||||
|  |             case: BinaryTreeCase[ | ||||||
|  |                 ActiveKeyType, MetaDataType, TreeType | ||||||
|  |             ] | ||||||
|  |     ): | ||||||
|  |         self.case = case | ||||||
|  | 
 | ||||||
|  |     def inner( | ||||||
|  |             self, | ||||||
|  |             split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType] | ||||||
|  |     ) -> TreeType: | ||||||
|  |         raise NotImplementedError | ||||||
|  | 
 | ||||||
|  |     def outer( | ||||||
|  |             self, | ||||||
|  |             split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType] | ||||||
|  |     ) -> TreeType: | ||||||
|  |         raise NotImplementedError | ||||||
|  | 
 | ||||||
|  |     def tree( | ||||||
|  |             self, | ||||||
|  |             inner: TreeType, | ||||||
|  |             outer: TreeType, | ||||||
|  |             key: HashPoint[ActiveKeyType] | ||||||
|  |     ) -> TreeType: | ||||||
|  |         raise NotImplementedError | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class InnerOuter(Symmetric): | ||||||
|  |     def inner( | ||||||
|  |             self, | ||||||
|  |             split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType] | ||||||
|  |     ) -> TreeType: | ||||||
|  |         return split.treel | ||||||
|  | 
 | ||||||
|  |     def outer( | ||||||
|  |             self, | ||||||
|  |             split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType] | ||||||
|  |     ) -> TreeType: | ||||||
|  |         return split.treer | ||||||
|  | 
 | ||||||
|  |     def tree( | ||||||
|  |             self, | ||||||
|  |             inner: TreeType, | ||||||
|  |             outer: TreeType, | ||||||
|  |             key: HashPoint[ActiveKeyType] | ||||||
|  |     ) -> TreeType: | ||||||
|  |         return self.case.protocol.tree(inner, outer, key) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class OuterInner(Symmetric): | ||||||
|  |     def inner( | ||||||
|  |             self, | ||||||
|  |             split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType] | ||||||
|  |     ) -> TreeType: | ||||||
|  |         return split.treer | ||||||
|  | 
 | ||||||
|  |     def outer( | ||||||
|  |             self, | ||||||
|  |             split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType] | ||||||
|  |     ) -> TreeType: | ||||||
|  |         return split.treel | ||||||
|  | 
 | ||||||
|  |     def tree( | ||||||
|  |             self, | ||||||
|  |             inner: TreeType, | ||||||
|  |             outer: TreeType, | ||||||
|  |             key: HashPoint[ActiveKeyType] | ||||||
|  |     ) -> TreeType: | ||||||
|  |         return self.case.protocol.tree(outer, inner, key) | ||||||
| @ -1,5 +1,9 @@ | |||||||
| from typing import Generic, Optional, TypeVar | from typing import Generic, Optional, TypeVar | ||||||
| 
 | 
 | ||||||
|  | from rainbowadn.core.hashpoint import HashPoint | ||||||
|  | from rainbowadn.core.nullability.null import Null | ||||||
|  | from rainbowadn.core.nullability.nullablereference import NullableReference | ||||||
|  | from rainbowadn.core.rainbow_factory import RainbowFactory | ||||||
| from rainbowadn.data.collection.collection_interface.collectioninterface import CollectionInterface | from rainbowadn.data.collection.collection_interface.collectioninterface import CollectionInterface | ||||||
| from rainbowadn.data.collection.keymetadata import KeyMetadata, KeyMetadataFactory | from rainbowadn.data.collection.keymetadata import KeyMetadata, KeyMetadataFactory | ||||||
| from rainbowadn.data.collection.trees.binary.actions.stdactions import AddAction, ContainsAction, RemoveAction | from rainbowadn.data.collection.trees.binary.actions.stdactions import AddAction, ContainsAction, RemoveAction | ||||||
| @ -8,10 +12,6 @@ from rainbowadn.data.collection.trees.binary.binarytree import BinaryTree, Binar | |||||||
| from rainbowadn.data.collection.trees.binary.binarytreebalancingprotocol import BinaryTreeBalancingProtocol | from rainbowadn.data.collection.trees.binary.binarytreebalancingprotocol import BinaryTreeBalancingProtocol | ||||||
| from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol | from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol | ||||||
| from rainbowadn.data.collection.trees.binary.binarytreesplit import BinaryTreeSplit | from rainbowadn.data.collection.trees.binary.binarytreesplit import BinaryTreeSplit | ||||||
| from rainbowadn.core.hashpoint import HashPoint |  | ||||||
| from rainbowadn.core.nullability.null import Null |  | ||||||
| from rainbowadn.core.nullability.nullablereference import NullableReference |  | ||||||
| from rainbowadn.core.rainbow_factory import RainbowFactory |  | ||||||
| 
 | 
 | ||||||
| __all__ = ('ActiveBinaryTree',) | __all__ = ('ActiveBinaryTree',) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,17 +1,20 @@ | |||||||
| from typing import TypeVar | from typing import Generic, TypeVar | ||||||
| 
 | 
 | ||||||
| from rainbowadn.data.atomic.integer import Integer |  | ||||||
| from rainbowadn.data.collection.trees.binary.binarytreebalancingprotocol import BinaryTreeBalancingProtocol |  | ||||||
| from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol |  | ||||||
| from rainbowadn.core.hashpoint import HashPoint | from rainbowadn.core.hashpoint import HashPoint | ||||||
|  | from rainbowadn.data.atomic.integer import Integer | ||||||
|  | from rainbowadn.data.collection.trees.binary.actions.binarytreeaction import BinaryTreeAction | ||||||
|  | from rainbowadn.data.collection.trees.binary.actions.symmetric import InnerOuter, OuterInner, Symmetric | ||||||
|  | from rainbowadn.data.collection.trees.binary.binarytreebalancingprotocol import BinaryTreeBalancingProtocol | ||||||
|  | from rainbowadn.data.collection.trees.binary.binarytreecase import BinaryTreeCase | ||||||
|  | from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol | ||||||
| 
 | 
 | ||||||
| __all__ = ('AVLBTBP',) | __all__ = ('AVL',) | ||||||
| 
 | 
 | ||||||
| ActiveKeyType = TypeVar('ActiveKeyType') | ActiveKeyType = TypeVar('ActiveKeyType') | ||||||
| TreeType = TypeVar('TreeType') | TreeType = TypeVar('TreeType') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class AVLBTBP(BinaryTreeBalancingProtocol[ActiveKeyType, Integer, TreeType]): | class AVL(BinaryTreeBalancingProtocol[ActiveKeyType, Integer, TreeType]): | ||||||
|     def empty_metadata(self) -> HashPoint[Integer]: |     def empty_metadata(self) -> HashPoint[Integer]: | ||||||
|         return HashPoint.of(Integer(0)) |         return HashPoint.of(Integer(0)) | ||||||
| 
 | 
 | ||||||
| @ -32,50 +35,76 @@ class AVLBTBP(BinaryTreeBalancingProtocol[ActiveKeyType, Integer, TreeType]): | |||||||
|             tree: TreeType, |             tree: TreeType, | ||||||
|             protocol: BinaryTreeCreationProtocol[ActiveKeyType, Integer, TreeType] |             protocol: BinaryTreeCreationProtocol[ActiveKeyType, Integer, TreeType] | ||||||
|     ) -> int: |     ) -> int: | ||||||
|         if (split := protocol.split(tree)) is None: |         return HeightAction().on(protocol, tree) | ||||||
|             return 0 |  | ||||||
|         else: |  | ||||||
|             return split.metadata.resolve().integer |  | ||||||
| 
 | 
 | ||||||
|     def balance( |     def balance( | ||||||
|             self, |             self, | ||||||
|             tree: TreeType, |             tree: TreeType, | ||||||
|             protocol: BinaryTreeCreationProtocol[ActiveKeyType, Integer, TreeType] |             protocol: BinaryTreeCreationProtocol[ActiveKeyType, Integer, TreeType] | ||||||
|     ) -> TreeType: |     ) -> TreeType: | ||||||
|         if (split := protocol.split(tree)) is None: |         return BalanceAction().on(protocol, tree) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class HeightAction( | ||||||
|  |     BinaryTreeAction[ActiveKeyType, Integer, TreeType, int], | ||||||
|  |     Generic[ActiveKeyType, TreeType] | ||||||
|  | ): | ||||||
|  |     def on_null( | ||||||
|  |             self, | ||||||
|  |             protocol: BinaryTreeCreationProtocol[ActiveKeyType, Integer, TreeType], | ||||||
|  |             tree: TreeType | ||||||
|  |     ) -> int: | ||||||
|  |         return 0 | ||||||
|  | 
 | ||||||
|  |     def on_split( | ||||||
|  |             self, | ||||||
|  |             case: BinaryTreeCase[ActiveKeyType, Integer, TreeType] | ||||||
|  |     ) -> int: | ||||||
|  |         return case.split.metadata.resolve().integer | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class BalanceAction( | ||||||
|  |     BinaryTreeAction[ActiveKeyType, Integer, TreeType, TreeType], | ||||||
|  |     Generic[ActiveKeyType, TreeType] | ||||||
|  | ): | ||||||
|  |     def on_null( | ||||||
|  |             self, | ||||||
|  |             protocol: BinaryTreeCreationProtocol[ActiveKeyType, Integer, TreeType], | ||||||
|  |             tree: TreeType | ||||||
|  |     ) -> TreeType: | ||||||
|         return tree |         return tree | ||||||
|         else: | 
 | ||||||
|             delta = self.height(split.treel, protocol) - self.height(split.treer, protocol) |     def on_split( | ||||||
|  |             self, | ||||||
|  |             case: BinaryTreeCase[ActiveKeyType, Integer, TreeType] | ||||||
|  |     ) -> TreeType: | ||||||
|  |         split, protocol = case.split, case.protocol | ||||||
|  |         delta = AVL.height(split.treel, protocol) - AVL.height(split.treer, protocol) | ||||||
|         assert isinstance(delta, int) |         assert isinstance(delta, int) | ||||||
|         if delta < -1: |         if delta < -1: | ||||||
|                 assert (splitr := protocol.split(split.treer)) is not None |             return self.on_symmetric(InnerOuter(case)) | ||||||
|                 if self.height(splitr.treel, protocol) > self.height(splitr.treer, protocol): |  | ||||||
|                     assert (splitrl := protocol.split(splitr.treel)) is not None |  | ||||||
|                     return protocol.tree( |  | ||||||
|                         protocol.tree(split.treel, splitrl.treel, split.key), |  | ||||||
|                         protocol.tree(splitrl.treer, splitr.treer, splitr.key), |  | ||||||
|                         splitrl.key |  | ||||||
|                     ) |  | ||||||
|                 else: |  | ||||||
|                     return protocol.tree( |  | ||||||
|                         protocol.tree(split.treel, splitr.treel, split.key), |  | ||||||
|                         splitr.treer, |  | ||||||
|                         splitr.key |  | ||||||
|                     ) |  | ||||||
|         elif delta > 1: |         elif delta > 1: | ||||||
|                 assert (splitl := protocol.split(split.treel)) is not None |             return self.on_symmetric(OuterInner(case)) | ||||||
|                 if self.height(splitl.treer, protocol) > self.height(splitl.treel, protocol): |         else: | ||||||
|                     assert (splitlr := protocol.split(splitl.treer)) is not None |             return case.tree | ||||||
|                     return protocol.tree( | 
 | ||||||
|                         protocol.tree(splitl.treel, splitlr.treel, splitl.key), |     @classmethod | ||||||
|                         protocol.tree(splitlr.treer, split.treer, split.key), |     def on_symmetric( | ||||||
|                         splitlr.key |             cls, | ||||||
|  |             symmetric: Symmetric[ActiveKeyType, Integer, TreeType] | ||||||
|  |     ) -> TreeType: | ||||||
|  |         protocol, split = symmetric.case.protocol, symmetric.case.split | ||||||
|  |         splito = protocol.fsplit(symmetric.outer(split)) | ||||||
|  |         if AVL.height(symmetric.inner(splito), protocol) > AVL.height(symmetric.outer(splito), protocol): | ||||||
|  |             splitoi = protocol.fsplit(symmetric.inner(splito)) | ||||||
|  |             return symmetric.tree( | ||||||
|  |                 symmetric.tree(symmetric.inner(split), symmetric.inner(splitoi), split.key), | ||||||
|  |                 symmetric.tree(symmetric.outer(splitoi), symmetric.outer(splito), splito.key), | ||||||
|  |                 splitoi.key | ||||||
|             ) |             ) | ||||||
|         else: |         else: | ||||||
|                     return protocol.tree( |             return symmetric.tree( | ||||||
|                         splitl.treel, |                 symmetric.tree(symmetric.inner(split), symmetric.inner(splito), split.key), | ||||||
|                         protocol.tree(splitl.treer, split.treer, split.key), |                 symmetric.outer(splito), | ||||||
|                         splitl.key |                 splito.key | ||||||
|             ) |             ) | ||||||
|             else: |  | ||||||
|                 return tree |  | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| import abc | import abc | ||||||
| from typing import Generic, TypeVar | from typing import Generic, TypeVar | ||||||
| 
 | 
 | ||||||
|  | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.data.collection.trees.binary.binarytreebalancingprotocol import BinaryTreeBalancingProtocol | from rainbowadn.data.collection.trees.binary.binarytreebalancingprotocol import BinaryTreeBalancingProtocol | ||||||
| from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol | from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol | ||||||
| from rainbowadn.core.hashpoint import HashPoint |  | ||||||
| 
 | 
 | ||||||
| __all__ = ('BalancedTreeCreationProtocol',) | __all__ = ('BalancedTreeCreationProtocol',) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| from typing import Generic, TypeVar | from typing import Generic, TypeVar | ||||||
| 
 | 
 | ||||||
|  | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol | from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol | ||||||
| from rainbowadn.data.collection.trees.comparison.comparator import Comparator | from rainbowadn.data.collection.trees.comparison.comparator import Comparator | ||||||
| from rainbowadn.core.hashpoint import HashPoint |  | ||||||
| 
 | 
 | ||||||
| __all__ = ('BinaryTreeBalancingProtocol',) | __all__ = ('BinaryTreeBalancingProtocol',) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -16,7 +16,9 @@ class BinaryTreeCase( | |||||||
|     def __init__( |     def __init__( | ||||||
|             self, |             self, | ||||||
|             protocol: BinaryTreeCreationProtocol[ActiveKeyType, MetaDataType, TreeType], |             protocol: BinaryTreeCreationProtocol[ActiveKeyType, MetaDataType, TreeType], | ||||||
|             split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType] |             split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType], | ||||||
|  |             tree: TreeType | ||||||
|     ): |     ): | ||||||
|         self.protocol = protocol |         self.protocol = protocol | ||||||
|         self.split = split |         self.split = split | ||||||
|  |         self.tree = tree | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| from typing import Generic, Optional, TypeVar | from typing import Generic, Optional, TypeVar | ||||||
| 
 | 
 | ||||||
|  | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.data.collection.trees.binary.binarytreesplit import BinaryTreeSplit | from rainbowadn.data.collection.trees.binary.binarytreesplit import BinaryTreeSplit | ||||||
| from rainbowadn.data.collection.trees.comparison.comparator import Comparator | from rainbowadn.data.collection.trees.comparison.comparator import Comparator | ||||||
| from rainbowadn.core.hashpoint import HashPoint |  | ||||||
| 
 | 
 | ||||||
| __all__ = ('BinaryTreeCreationProtocol',) | __all__ = ('BinaryTreeCreationProtocol',) | ||||||
| 
 | 
 | ||||||
| @ -21,5 +21,12 @@ class BinaryTreeCreationProtocol(Generic[ActiveKeyType, MetaDataType, TreeType]) | |||||||
|         """result of this method is supposed to be used right after the call, therefore all values are resolved""" |         """result of this method is supposed to be used right after the call, therefore all values are resolved""" | ||||||
|         raise NotImplementedError |         raise NotImplementedError | ||||||
| 
 | 
 | ||||||
|  |     def fsplit(self, tree: TreeType) -> BinaryTreeSplit[ | ||||||
|  |         ActiveKeyType, MetaDataType, TreeType | ||||||
|  |     ]: | ||||||
|  |         split = self.split(tree) | ||||||
|  |         assert split is not None | ||||||
|  |         return split | ||||||
|  | 
 | ||||||
|     def tree(self, treel: TreeType, treer: TreeType, key: HashPoint[ActiveKeyType]) -> TreeType: |     def tree(self, treel: TreeType, treer: TreeType, key: HashPoint[ActiveKeyType]) -> TreeType: | ||||||
|         raise NotImplementedError |         raise NotImplementedError | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| from typing import Generic, TypeVar | from typing import Generic, TypeVar | ||||||
| 
 | 
 | ||||||
|  | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Left, Right | from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Left, Right | ||||||
| from rainbowadn.data.collection.trees.comparison.protocolcomparator import ProtocolComparator | from rainbowadn.data.collection.trees.comparison.protocolcomparator import ProtocolComparator | ||||||
| from rainbowadn.core.hashpoint import HashPoint |  | ||||||
| 
 | 
 | ||||||
| __all__ = ('HashComparator',) | __all__ = ('HashComparator',) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| from typing import Generic, TypeVar | from typing import Generic, TypeVar | ||||||
| 
 | 
 | ||||||
|  | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.data.collection.keyed import Keyed | from rainbowadn.data.collection.keyed import Keyed | ||||||
| from rainbowadn.data.collection.trees.comparison.comparator import Comparator, Comparison | from rainbowadn.data.collection.trees.comparison.comparator import Comparator, Comparison | ||||||
| from rainbowadn.core.hashpoint import HashPoint |  | ||||||
| 
 | 
 | ||||||
| __all__ = ('KeyedComparator',) | __all__ = ('KeyedComparator',) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
|  | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.data.atomic.plain import Plain | from rainbowadn.data.atomic.plain import Plain | ||||||
| from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Left, Right | from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Left, Right | ||||||
| from rainbowadn.data.collection.trees.comparison.protocolcomparator import ProtocolComparator | from rainbowadn.data.collection.trees.comparison.protocolcomparator import ProtocolComparator | ||||||
| from rainbowadn.core.hashpoint import HashPoint |  | ||||||
| 
 | 
 | ||||||
| __all__ = ('PlainComparator',) | __all__ = ('PlainComparator',) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -9,18 +9,18 @@ import nacl.signing | |||||||
| from rainbowadn.chain.blockchain import BlockChainFactory | from rainbowadn.chain.blockchain import BlockChainFactory | ||||||
| from rainbowadn.chain.chaincollectioninterface import ChainCollectionInterface | from rainbowadn.chain.chaincollectioninterface import ChainCollectionInterface | ||||||
| from rainbowadn.chain.reduction.reductionchainmetafactory import ReductionChainMetaFactory | from rainbowadn.chain.reduction.reductionchainmetafactory import ReductionChainMetaFactory | ||||||
| from rainbowadn.data.atomic.integer import Integer |  | ||||||
| from rainbowadn.data.atomic.plain import Plain |  | ||||||
| from rainbowadn.data.collection.pair import Pair, PairFactory |  | ||||||
| from rainbowadn.data.collection.trees.binary.activebinarytree import ActiveBinaryTree |  | ||||||
| from rainbowadn.data.collection.trees.binary.avl import AVLBTBP |  | ||||||
| from rainbowadn.data.collection.trees.comparison.comparator import Replace |  | ||||||
| from rainbowadn.data.collection.trees.comparison.plaincomparator import PlainComparator |  | ||||||
| from rainbowadn.encryption.encrypted import Encrypted |  | ||||||
| from rainbowadn.core.hashpoint import HashPoint | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.core.nullability.notnull import NotNull | from rainbowadn.core.nullability.notnull import NotNull | ||||||
| from rainbowadn.core.rainbow_factory import RainbowFactory | from rainbowadn.core.rainbow_factory import RainbowFactory | ||||||
| from rainbowadn.core.resolvermetaorigin import ResolverMetaOrigin | from rainbowadn.core.resolvermetaorigin import ResolverMetaOrigin | ||||||
|  | from rainbowadn.data.atomic.integer import Integer | ||||||
|  | from rainbowadn.data.atomic.plain import Plain | ||||||
|  | from rainbowadn.data.collection.pair import Pair, PairFactory | ||||||
|  | from rainbowadn.data.collection.trees.binary.activebinarytree import ActiveBinaryTree | ||||||
|  | from rainbowadn.data.collection.trees.binary.avl import AVL | ||||||
|  | from rainbowadn.data.collection.trees.comparison.comparator import Replace | ||||||
|  | from rainbowadn.data.collection.trees.comparison.plaincomparator import PlainComparator | ||||||
|  | from rainbowadn.encryption.encrypted import Encrypted | ||||||
| from rainbowadn.testing.dictresolver import DictResolver | from rainbowadn.testing.dictresolver import DictResolver | ||||||
| from rainbowadn.testing.instrumentation import Counter | from rainbowadn.testing.instrumentation import Counter | ||||||
| from rainbowadn.v13.algo import MINT_CONST | from rainbowadn.v13.algo import MINT_CONST | ||||||
| @ -142,7 +142,7 @@ class TestAll(unittest.TestCase): | |||||||
| 
 | 
 | ||||||
|     def test_avl(self): |     def test_avl(self): | ||||||
|         tree: ActiveBinaryTree[Plain, Integer] = ActiveBinaryTree.empty( |         tree: ActiveBinaryTree[Plain, Integer] = ActiveBinaryTree.empty( | ||||||
|             AVLBTBP(PlainComparator(Replace())), Plain.factory() |             AVL(PlainComparator(Replace())), Plain.factory() | ||||||
|         ) |         ) | ||||||
|         for i in range(26): |         for i in range(26): | ||||||
|             tree = tree.add(HashPoint.of(Plain(bytes([ord('A') + i])))) |             tree = tree.add(HashPoint.of(Plain(bytes([ord('A') + i])))) | ||||||
| @ -150,7 +150,7 @@ class TestAll(unittest.TestCase): | |||||||
| 
 | 
 | ||||||
|     def test_avl_stress(self): |     def test_avl_stress(self): | ||||||
|         tree: ActiveBinaryTree[Plain, Integer] = ActiveBinaryTree.empty( |         tree: ActiveBinaryTree[Plain, Integer] = ActiveBinaryTree.empty( | ||||||
|             AVLBTBP(PlainComparator(Replace())), Plain.factory() |             AVL(PlainComparator(Replace())), Plain.factory() | ||||||
|         ) |         ) | ||||||
|         for i in range(250): |         for i in range(250): | ||||||
|             tree = tree.add(HashPoint.of(Plain(os.urandom(16)))) |             tree = tree.add(HashPoint.of(Plain(os.urandom(16)))) | ||||||
| @ -163,7 +163,7 @@ class TestAll(unittest.TestCase): | |||||||
|             dr = DictResolver() |             dr = DictResolver() | ||||||
|         with self.subTest('create empty'): |         with self.subTest('create empty'): | ||||||
|             tree: ActiveBinaryTree[Plain, Integer] = ActiveBinaryTree.empty( |             tree: ActiveBinaryTree[Plain, Integer] = ActiveBinaryTree.empty( | ||||||
|                 AVLBTBP(PlainComparator(Replace())), Plain.factory() |                 AVL(PlainComparator(Replace())), Plain.factory() | ||||||
|             ) |             ) | ||||||
|         with self.subTest('fill'): |         with self.subTest('fill'): | ||||||
|             for char in string.ascii_uppercase: |             for char in string.ascii_uppercase: | ||||||
|  | |||||||
| @ -9,7 +9,6 @@ from rainbowadn.toplevel.thresholdprotocol import ThresholdProtocol | |||||||
| 
 | 
 | ||||||
| __all__ = ('ValidReference', 'ValidReferenceFactory') | __all__ = ('ValidReference', 'ValidReferenceFactory') | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| Referenced = TypeVar('Referenced') | Referenced = TypeVar('Referenced') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,9 +2,9 @@ from typing import Generic, TypeVar | |||||||
| 
 | 
 | ||||||
| from rainbowadn.chain.abstractreductionchainmetafactory import AbstractReductionChainMetaFactory | from rainbowadn.chain.abstractreductionchainmetafactory import AbstractReductionChainMetaFactory | ||||||
| from rainbowadn.chain.chaincollectioninterface import ChainCollectionInterface | from rainbowadn.chain.chaincollectioninterface import ChainCollectionInterface | ||||||
| from rainbowadn.data.collection.stack.stack import Stack, StackFactory |  | ||||||
| from rainbowadn.core.hashpoint import HashPoint | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.core.nullability.nullablereference import NullableReference, NullableReferenceFactory | from rainbowadn.core.nullability.nullablereference import NullableReference, NullableReferenceFactory | ||||||
|  | from rainbowadn.data.collection.stack.stack import Stack, StackFactory | ||||||
| from rainbowadn.v13.bankprotocol import BankProtocol | from rainbowadn.v13.bankprotocol import BankProtocol | ||||||
| from rainbowadn.v13.bankstate import BankState | from rainbowadn.v13.bankstate import BankState | ||||||
| from rainbowadn.v13.transaction import Transaction | from rainbowadn.v13.transaction import Transaction | ||||||
|  | |||||||
| @ -2,15 +2,15 @@ from rainbowadn.chain.reduction.reduced import Reduced | |||||||
| from rainbowadn.chain.reduction.reduction import Reduction | from rainbowadn.chain.reduction.reduction import Reduction | ||||||
| from rainbowadn.chain.reduction.reductionprotocol import ReductionProtocol | from rainbowadn.chain.reduction.reductionprotocol import ReductionProtocol | ||||||
| from rainbowadn.chain.reduction.reductionresult import ReductionResult | from rainbowadn.chain.reduction.reductionresult import ReductionResult | ||||||
| from rainbowadn.data.atomic.integer import Integer |  | ||||||
| from rainbowadn.data.collection.keymetadata import KeyMetadataFactory |  | ||||||
| from rainbowadn.data.collection.stack.stack import Stack |  | ||||||
| from rainbowadn.data.collection.trees.binary.binarytree import BinaryTreeFactory |  | ||||||
| from rainbowadn.core.hashpoint import HashPoint | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.core.nullability.null import Null | from rainbowadn.core.nullability.null import Null | ||||||
| from rainbowadn.core.nullability.nullablereference import NullableReference | from rainbowadn.core.nullability.nullablereference import NullableReference | ||||||
| from rainbowadn.core.rainbow_factory import RainbowFactory | from rainbowadn.core.rainbow_factory import RainbowFactory | ||||||
| from rainbowadn.core.static import StaticFactory | from rainbowadn.core.static import StaticFactory | ||||||
|  | from rainbowadn.data.atomic.integer import Integer | ||||||
|  | from rainbowadn.data.collection.keymetadata import KeyMetadataFactory | ||||||
|  | from rainbowadn.data.collection.stack.stack import Stack | ||||||
|  | from rainbowadn.data.collection.trees.binary.binarytree import BinaryTreeFactory | ||||||
| from rainbowadn.v13.bankstate import BankState | from rainbowadn.v13.bankstate import BankState | ||||||
| from rainbowadn.v13.subject import Subject | from rainbowadn.v13.subject import Subject | ||||||
| from rainbowadn.v13.transaction import Coin, Transaction | from rainbowadn.v13.transaction import Coin, Transaction | ||||||
|  | |||||||
| @ -1,12 +1,5 @@ | |||||||
| from typing import Iterable | from typing import Iterable | ||||||
| 
 | 
 | ||||||
| from rainbowadn.data.atomic.integer import Integer |  | ||||||
| from rainbowadn.data.collection.keymetadata import KeyMetadata, KeyMetadataFactory |  | ||||||
| from rainbowadn.data.collection.trees.binary.activebinarytree import ActiveBinaryTree |  | ||||||
| from rainbowadn.data.collection.trees.binary.avl import AVLBTBP |  | ||||||
| from rainbowadn.data.collection.trees.binary.binarytree import BinaryTree, BinaryTreeFactory |  | ||||||
| from rainbowadn.data.collection.trees.comparison.comparator import Fail |  | ||||||
| from rainbowadn.data.collection.trees.comparison.hashcomparator import HashComparator |  | ||||||
| from rainbowadn.core.hash_point_format import hash_point_format, tabulate | from rainbowadn.core.hash_point_format import hash_point_format, tabulate | ||||||
| from rainbowadn.core.hashpoint import HashPoint | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.core.hashresolver import HashResolver | from rainbowadn.core.hashresolver import HashResolver | ||||||
| @ -17,6 +10,13 @@ from rainbowadn.core.rainbow_factory import RainbowFactory | |||||||
| from rainbowadn.core.recursivementionable import RecursiveMentionable | from rainbowadn.core.recursivementionable import RecursiveMentionable | ||||||
| from rainbowadn.core.resolverorigin import ResolverOrigin | from rainbowadn.core.resolverorigin import ResolverOrigin | ||||||
| from rainbowadn.core.static import StaticFactory, StaticMentionable | from rainbowadn.core.static import StaticFactory, StaticMentionable | ||||||
|  | from rainbowadn.data.atomic.integer import Integer | ||||||
|  | from rainbowadn.data.collection.keymetadata import KeyMetadata, KeyMetadataFactory | ||||||
|  | from rainbowadn.data.collection.trees.binary.activebinarytree import ActiveBinaryTree | ||||||
|  | from rainbowadn.data.collection.trees.binary.avl import AVL | ||||||
|  | from rainbowadn.data.collection.trees.binary.binarytree import BinaryTree, BinaryTreeFactory | ||||||
|  | from rainbowadn.data.collection.trees.comparison.comparator import Fail | ||||||
|  | from rainbowadn.data.collection.trees.comparison.hashcomparator import HashComparator | ||||||
| from rainbowadn.v13.algo import MINT_CONST | from rainbowadn.v13.algo import MINT_CONST | ||||||
| from rainbowadn.v13.subject import Subject | from rainbowadn.v13.subject import Subject | ||||||
| from rainbowadn.v13.transaction import Coin, Transaction | from rainbowadn.v13.transaction import Coin, Transaction | ||||||
| @ -89,12 +89,12 @@ class BankState(RecursiveMentionable, StaticMentionable): | |||||||
| 
 | 
 | ||||||
|     def minted_tree(self) -> ActiveBinaryTree[Coin, Integer]: |     def minted_tree(self) -> ActiveBinaryTree[Coin, Integer]: | ||||||
|         return ActiveBinaryTree( |         return ActiveBinaryTree( | ||||||
|             AVLBTBP(HashComparator(Fail())), self.minted |             AVL(HashComparator(Fail())), self.minted | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|     def used_tree(self) -> ActiveBinaryTree[Coin, Integer]: |     def used_tree(self) -> ActiveBinaryTree[Coin, Integer]: | ||||||
|         return ActiveBinaryTree( |         return ActiveBinaryTree( | ||||||
|             AVLBTBP(HashComparator(Fail())), self.used |             AVL(HashComparator(Fail())), self.used | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|     def use_coins(self, coins: Iterable[HashPoint[Coin]]) -> 'BankState': |     def use_coins(self, coins: Iterable[HashPoint[Coin]]) -> 'BankState': | ||||||
|  | |||||||
| @ -2,8 +2,8 @@ import nacl.bindings | |||||||
| import nacl.exceptions | import nacl.exceptions | ||||||
| import nacl.signing | import nacl.signing | ||||||
| 
 | 
 | ||||||
| from rainbowadn.data.atomic.atomic import Atomic |  | ||||||
| from rainbowadn.core.hashpoint import HashPoint | from rainbowadn.core.hashpoint import HashPoint | ||||||
|  | from rainbowadn.data.atomic.atomic import Atomic | ||||||
| from rainbowadn.v13.subject import Subject | from rainbowadn.v13.subject import Subject | ||||||
| 
 | 
 | ||||||
| __all__ = ('BadSignature', 'Signature',) | __all__ = ('BadSignature', 'Signature',) | ||||||
|  | |||||||
| @ -2,8 +2,6 @@ from typing import Iterable | |||||||
| 
 | 
 | ||||||
| import nacl.signing | import nacl.signing | ||||||
| 
 | 
 | ||||||
| from rainbowadn.data.atomic.integer import Integer |  | ||||||
| from rainbowadn.data.collection.stack.stack import Stack, StackFactory |  | ||||||
| from rainbowadn.core.hash_point_format import hash_point_format, tabulate | from rainbowadn.core.hash_point_format import hash_point_format, tabulate | ||||||
| from rainbowadn.core.hashpoint import HashPoint | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.core.hashresolver import HashResolver | from rainbowadn.core.hashresolver import HashResolver | ||||||
| @ -14,6 +12,8 @@ from rainbowadn.core.rainbow_factory import RainbowFactory | |||||||
| from rainbowadn.core.recursivementionable import RecursiveMentionable | from rainbowadn.core.recursivementionable import RecursiveMentionable | ||||||
| from rainbowadn.core.resolverorigin import ResolverOrigin | from rainbowadn.core.resolverorigin import ResolverOrigin | ||||||
| from rainbowadn.core.static import StaticMentionable | from rainbowadn.core.static import StaticMentionable | ||||||
|  | from rainbowadn.data.atomic.integer import Integer | ||||||
|  | from rainbowadn.data.collection.stack.stack import Stack, StackFactory | ||||||
| from rainbowadn.v13.signature import Signature | from rainbowadn.v13.signature import Signature | ||||||
| from rainbowadn.v13.subject import Subject | from rainbowadn.v13.subject import Subject | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,6 +1,5 @@ | |||||||
| from typing import Iterable | from typing import Iterable | ||||||
| 
 | 
 | ||||||
| from rainbowadn.data.atomic.integer import Integer |  | ||||||
| from rainbowadn.core.hash_point_format import hash_point_format, tabulate | from rainbowadn.core.hash_point_format import hash_point_format, tabulate | ||||||
| from rainbowadn.core.hashpoint import HashPoint | from rainbowadn.core.hashpoint import HashPoint | ||||||
| from rainbowadn.core.hashresolver import HashResolver | from rainbowadn.core.hashresolver import HashResolver | ||||||
| @ -10,6 +9,7 @@ from rainbowadn.core.mentionable import Mentionable | |||||||
| from rainbowadn.core.rainbow_factory import RainbowFactory | from rainbowadn.core.rainbow_factory import RainbowFactory | ||||||
| from rainbowadn.core.recursivementionable import RecursiveMentionable | from rainbowadn.core.recursivementionable import RecursiveMentionable | ||||||
| from rainbowadn.core.resolverorigin import ResolverOrigin | from rainbowadn.core.resolverorigin import ResolverOrigin | ||||||
|  | from rainbowadn.data.atomic.integer import Integer | ||||||
| from rainbowadn.wrisbt.weakreferenceindexsetbtree import WeakReferenceIndexSetBTree, WrisbtFactory | from rainbowadn.wrisbt.weakreferenceindexsetbtree import WeakReferenceIndexSetBTree, WrisbtFactory | ||||||
| from rainbowadn.wrisbt.wrisbtparametres import WrisbtParametres | from rainbowadn.wrisbt.wrisbtparametres import WrisbtParametres | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user