Did I find the right examples for you? yes no

All Samples(4)  |  Call(4)  |  Derive(0)  |  Import(0)
Generates an interator that merges the output of a list of iterators.  The
individual iterators must return values in sorted order, and the output of
this iterator will be sorted.

        def merge_sorted_iterators(iter_list):
    """
    Generates an interator that merges the output of a list of iterators.  The
    individual iterators must return values in sorted order, and the output of
    this iterator will be sorted.
    """
    # Prime the element heap
    heap = []
    for iterator in iter_list:
        for elem in iterator:
            heap.append( (elem, iterator) )
            break
    heapq.heapify(heap)

    # Now pull elements from the heap, refilling it from the iterators
    # as we go (except when the iterators are empty).
    while heap:
        value, iterator = heap[0]
        yield value
        for elem in iterator:
            heapq.heapreplace(heap, (elem, iterator))
            break
        else:
            heapq.heappop(heap)
        


src/g/r/GridBackup-HEAD/grid_backup/revlog.py   GridBackup(Download)
            iter_list.append(self._entry_reader(ver_file))
 
        merged = util.merge_sorted_iterators(iter_list)
 
        out_file = self._base_log.new_version(new_type, False, False)
            iter_list.append(self._entry_reader(ver_file))
 
        merged = util.merge_sorted_iterators(iter_list)
 
        out_file = self._base_log.new_version(new_type, False, False)

src/g/r/GridBackup-HEAD/grid_backup/snapshot.py   GridBackup(Download)
        # a single sorted iterator, and wrap a PushbackIter around it so we
        # can push back values we're not ready for yet.
        merged_iter = util.merge_sorted_iterators(log_iters)
        entry_iter = util.PushbackIter(merged_iter)
        for entry in entry_iter:

src/g/r/GridBackup-HEAD/grid_backup/tests/test_util.py   GridBackup(Download)
 
        iter_list = [ iter(l) for l in lst ]
        merger = util.merge_sorted_iterators(iter_list)
 
        count_map = {}