trees.py
def _help_balance(self, lst_x: list, lst_y: list) -> None:
        """
        Rebuild self as a balance tree from the <lst_x>, <lst_y>, which records
        all the points from original self in order.
        """
        lst0_x, lst1_x, lst0_y, lst1_y = [], [], [], []
        if self._split_type == 'x':
            if len(lst_x) == 1:
                self._point, self._name = lst_x[0]
            else:
                mid = len(lst_x) // 2
                while mid < len(lst_x) - 1 and lst_x[mid][0][0] == \
                        lst_x[mid + 1][0][0]:
                    mid += 1
                self._point, self._name = lst_x[mid]
                lst0_x = lst_x[:mid]
                if mid + 1 < len(lst_x):
                    lst1_x = lst_x[mid + 1:]
                for item in lst_y:
                    if item in lst0_x:
                        lst0_y.append(item)
                    elif item in lst1_x:
                        lst1_y.append(item)

        else:
            if len(lst_y) == 1:
                self._point, self._name = lst_y[0]
            else:
                mid = len(lst_y) // 2
                while mid < len(lst_y) - 1 and lst_y[mid][0][1] == \
                        lst_y[mid + 1][0][1]:
                    mid += 1
                self._point, self._name = lst_y[mid]
                lst0_y = lst_y[:mid]
                if mid + 1 < len(lst_x):
                    lst1_y = lst_y[mid + 1:]
                for item in lst_x:
                    if item in lst0_y:
                        lst0_x.append(item)
                    elif item in lst1_y:
                        lst1_x.append(item)
        if lst0_x:
            self._lt = TwoDTree(None, None)
            if self._split_type == 'x':
                self._lt._split_type = 'y'
            else:
                self._lt._split_type = 'x'
            self._lt._help_balance(lst0_x, lst0_y)
        if lst1_x:
            self._gt = TwoDTree(None, None)
            if self._split_type == 'x':
                self._gt._split_type = 'y'
            else:
                self._gt._split_type = 'x'
            self._gt._help_balance(lst1_x, lst1_y)

        Rebuild self as a balance tree from the <lst_x>, <lst_y>, which records
        all the points from original self in order.
        
Rebuild self as a balance tree from the , , which records
all the points from original self in order.
Rebuild self as a balance tree from the which records all the points from original self in order .
def _help_balance(self, lst_x: list, lst_y: list) -> None:
        lst0_x, lst1_x, lst0_y, lst1_y = [], [], [], []
        if self._split_type == 'x':
            if len(lst_x) == 1:
                self._point, self._name = lst_x[0]
            else:
                mid = len(lst_x) // 2
                while mid < len(lst_x) - 1 and lst_x[mid][0][0] == \
                        lst_x[mid + 1][0][0]:
                    mid += 1
                self._point, self._name = lst_x[mid]
                lst0_x = lst_x[:mid]
                if mid + 1 < len(lst_x):
                    lst1_x = lst_x[mid + 1:]
                for item in lst_y:
                    if item in lst0_x:
                        lst0_y.append(item)
                    elif item in lst1_x:
                        lst1_y.append(item)
        else:
            if len(lst_y) == 1:
                self._point, self._name = lst_y[0]
            else:
                mid = len(lst_y) // 2
                while mid < len(lst_y) - 1 and lst_y[mid][0][1] == \
                        lst_y[mid + 1][0][1]:
                    mid += 1
                self._point, self._name = lst_y[mid]
                lst0_y = lst_y[:mid]
                if mid + 1 < len(lst_x):
                    lst1_y = lst_y[mid + 1:]
                for item in lst_x:
                    if item in lst0_y:
                        lst0_x.append(item)
                    elif item in lst1_y:
                        lst1_x.append(item)
        if lst0_x:
            self._lt = TwoDTree(None, None)
            if self._split_type == 'x':
                self._lt._split_type = 'y'
            else:
                self._lt._split_type = 'x'
            self._lt._help_balance(lst0_x, lst0_y)
        if lst1_x:
            self._gt = TwoDTree(None, None)
            if self._split_type == 'x':
                self._gt._split_type = 'y'
            else:
                self._gt._split_type = 'x'
            self._gt._help_balance(lst1_x, lst1_y)
def _help_balance ( self , lst_x : list , lst_y : list ) -> None : lst0_x , lst1_x , lst0_y , lst1_y = [ ] , [ ] , [ ] , [ ] if self . _split_type == 'x' : if len ( lst_x ) == 1 : self . _point , self . _name = lst_x [ 0 ] else : mid = len ( lst_x ) // 2 while mid < len ( lst_x ) - 1 and lst_x [ mid ] [ 0 ] [ 0 ] == lst_x [ mid + 1 ] [ 0 ] [ 0 ] : mid += 1 self . _point , self . _name = lst_x [ mid ] lst0_x = lst_x [ : mid ] if mid + 1 < len ( lst_x ) : lst1_x = lst_x [ mid + 1 : ] for item in lst_y : if item in lst0_x : lst0_y . append ( item ) elif item in lst1_x : lst1_y . append ( item ) else : if len ( lst_y ) == 1 : self . _point , self . _name = lst_y [ 0 ] else : mid = len ( lst_y ) // 2 while mid < len ( lst_y ) - 1 and lst_y [ mid ] [ 0 ] [ 1 ] == lst_y [ mid + 1 ] [ 0 ] [ 1 ] : mid += 1 self . _point , self . _name = lst_y [ mid ] lst0_y = lst_y [ : mid ] if mid + 1 < len ( lst_x ) : lst1_y = lst_y [ mid + 1 : ] for item in lst_x : if item in lst0_y : lst0_x . append ( item ) elif item in lst1_y : lst1_x . append ( item ) if lst0_x : self . _lt = TwoDTree ( None , None ) if self . _split_type == 'x' : self . _lt . _split_type = 'y' else : self . _lt . _split_type = 'x' self . _lt . _help_balance ( lst0_x , lst0_y ) if lst1_x : self . _gt = TwoDTree ( None , None ) if self . _split_type == 'x' : self . _gt . _split_type = 'y' else : self . _gt . _split_type = 'x' self . _gt . _help_balance ( lst1_x , lst1_y )
Rebuild self as a balance tree from the <lst_x>, <lst_y>, which records
all the points from original self in order.
Rebuild self as a balance tree from the <lst_x > <lst_y > which records all the points from original self in order .
"""
        Rebuild self as a balance tree from the <lst_x>, <lst_y>, which records
        all the points from original self in order.
        """
self
lst_x
list
lst_y
list