Exemple #1
0
 def __new__(cls, key=None, root_data=None, comp=None,
             is_order_statistic=False):
     obj = object.__new__(cls)
     if key is None and root_data is not None:
         raise ValueError('Key required.')
     key = None if root_data is None else key
     root = TreeNode(key, root_data)
     root.is_root = True
     obj.root_idx = 0
     obj.tree, obj.size = ArrayForTrees(TreeNode, [root]), 1
     obj.comparator = lambda key1, key2: key1 < key2 \
                     if comp is None else comp
     obj.is_order_statistic = is_order_statistic
     return obj
Exemple #2
0
 def __new__(cls,
             key=None,
             root_data=None,
             comp=None,
             is_order_statistic=False,
             max_children=2,
             **kwargs):
     raise_if_backend_is_not_python(cls,
                                    kwargs.get('backend', Backend.PYTHON))
     obj = object.__new__(cls)
     if key is None and root_data is not None:
         raise ValueError('Key required.')
     key = None if root_data is None else key
     root = MAryTreeNode(key, root_data)
     root.is_root = True
     obj.root_idx = 0
     obj.max_children = max_children
     obj.tree, obj.size = ArrayForTrees(MAryTreeNode, [root]), 1
     obj.comparator = lambda key1, key2: key1 < key2 \
                     if comp is None else comp
     obj.is_order_statistic = is_order_statistic
     return obj