def __init__(self, capacity=None): """ :param capacity: 栈的容积 """ if capacity is None: self.array = Array() else: self.array = Array(capacity)
def __init__(self, capacity=None, arr=None): if arr is not None: # 构建一个大根堆,通过heapify操作 self._heapify(arr) return if capacity is None: self._data = Array() else: self._data = Array(capacity)
def __init__(self, capacity=None): if capacity is None: self.array = Array() else: self.array = Array(capacity)