# Path: pyalgs/algorithms/commons/util.py
# def less(a, b):
#     return cmp(a, b) < 0
# 
# def exchange(a, i, j):
#     tmp = a[j]
#     a[j] = a[i]
#     a[i] = tmp
# 
# def greater(a, b):
#     return cmp(a, b) > 0


from pyalgs.algorithms.commons.util import less, exchange, greater
        tmp = [0] * (self.N + 1)
        for k in range(self.N + 1):
            tmp[k] = self.pq[k]

        n = self.N
        while n >= 1:
            key = tmp[1]
            exchange(tmp, 1, n)
            n -= 1
            self.sink(tmp, 1, n)
            yield key

    @staticmethod
    def create():
        return MaxPQ()


class IndexMinPQ(object):

    keys = None
    pq = None
    qp = None
    N = 0

    def __init__(self, size):
        self.keys = [None] * (size+1)
        self.pq = [0] * (size+1)
        self.qp = [0] * (size+1)

    def insert(self, index, key):

# Path: pyalgs/algorithms/commons/util.py
# def less(a, b):
#     return cmp(a, b) < 0
# 
# def exchange(a, i, j):
#     tmp = a[j]
#     a[j] = a[i]
#     a[i] = tmp
# 
# def greater(a, b):
#     return cmp(a, b) > 0


# Path: pyalgs/data_structures/commons/priority_queue.py
from pyalgs.algorithms.commons.util import less, exchange, greater

        tmp = [0] * (self.N + 1)
        for k in range(self.N + 1):
            tmp[k] = self.pq[k]

        n = self.N
        while n >= 1:
            key = tmp[1]
            exchange(tmp, 1, n)
            n -= 1
            self.sink(tmp, 1, n)
            yield key

    @staticmethod
    def create():
        return MaxPQ()


class IndexMinPQ(object):

    keys = None
    pq = None
    qp = None
    N = 0

    def __init__(self, size):
        self.keys = [None] * (size+1)
        self.pq = [0] * (size+1)
        self.qp = [0] * (size+1)

    def insert(self, index, key):

        self.keys[index] = key