remove power of 2 optimization

This commit is contained in:
Pepijn 2025-03-11 13:29:55 +01:00
parent 841d54c050
commit 6a8be97bb5
1 changed files with 3 additions and 6 deletions

View File

@ -72,14 +72,11 @@ class SumTree:
def __init__(self, capacity: int): def __init__(self, capacity: int):
""" """
Args: Args:
capacity: Maximum number of elements. The tree size is the next power of 2 for efficiency. capacity: Maximum number of elements.
""" """
self.capacity = capacity self.capacity = capacity
self.size = 1 self.size = capacity
while self.size < capacity: self.tree = [0.0] * (2 * self.size)
self.size *= 2 # Ensure power-of-two size for efficient updates
self.tree = [0.0] * (2 * self.size) # Tree structure
def initialize_tree(self, priorities: List[float]): def initialize_tree(self, priorities: List[float]):
""" """