def heap_sorting(self): queue = ProQueue() queue.init_by_array(self.array) #print queue.array array = [] while(queue.size() > 0): array.append(queue.pop().value) return array
def build_queue(h_lines, v_lines): h_queue = ProQueue() for line in h_lines: assert line[0][1] == line[1][1] y = line[0][1] start = line[0][0] end = line[1][0] if start < end: start, end = end, start # print line, start, end h_queue.push(QueueNode(start, (y, end))) h_queue.push(QueueNode(end, (y))) v_queue = ProQueue() for line in v_lines: # print line assert line[0][0] == line[1][0] x = line[0][0] if line[1][1] > line[0][1]: v_queue.push(QueueNode(x, (line[0][1], line[1][1]))) else: v_queue.push(QueueNode(x, (line[1][1], line[0][1]))) # print "v_queue", v_queue.get_keys() return h_queue, v_queue