aboutsummaryrefslogtreecommitdiff
path: root/circuitpython/tools/huffman/tests/util.py
blob: 8ff3cbd8d13319ff84751b2bf5d195b324adda3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from __future__ import absolute_import, print_function


def is_sorted(i):
    i = iter(i)
    try:
        a = next(i)
    except StopIteration:
        # zero length iterable
        return True
    for b in i:
        if a > b:
            return False
    return True


def popper(heap):
    while heap:
        yield heap.pop()