# Path: muninn/_compat.py
# PY3 = sys.version_info[0] == 3
#     def is_python2_unicode(x):
#     def dictkeys(d):
#     def dictvalues(d):
#     def path_utf8(path):
#     def encode(s):
#     def decode(s):
#     def is_python2_unicode(x):
#     def path_utf8(path):
#     def decode(s):
#     def encode(s):


from muninn._compat import itervalues, imap, izip
    from collections.abc import MutableSet
    from collections import MutableSet

    def __repr__(self):
        return "Prototype(name=%r, argument_types=%r, return_type=%r)" % (self.name, self.argument_types,
                                                                          self.return_type)

    def __hash__(self):
        return hash(self.id)


class FunctionTable(MutableSet):
    def __init__(self, prototypes=[], type_map=None):
        self._prototypes = {}
        self._type_map = type_map
        for prototype in prototypes:
            self.add(prototype)

    def __contains__(self, prototype):
        try:
            prototypes = self._prototypes[prototype.name]
        except KeyError:
            return False
        else:
            return prototype in prototypes

    def __iter__(self):
        for prototypes in itervalues(self._prototypes):
            for prototype in prototypes:
                yield prototype

    def __len__(self):

# Path: muninn/_compat.py
# PY3 = sys.version_info[0] == 3
#     def is_python2_unicode(x):
#     def dictkeys(d):
#     def dictvalues(d):
#     def path_utf8(path):
#     def encode(s):
#     def decode(s):
#     def is_python2_unicode(x):
#     def path_utf8(path):
#     def decode(s):
#     def encode(s):


# Path: muninn/function.py
from muninn._compat import itervalues, imap, izip
    from collections.abc import MutableSet
    from collections import MutableSet


    def __repr__(self):
        return "Prototype(name=%r, argument_types=%r, return_type=%r)" % (self.name, self.argument_types,
                                                                          self.return_type)

    def __hash__(self):
        return hash(self.id)


class FunctionTable(MutableSet):
    def __init__(self, prototypes=[], type_map=None):
        self._prototypes = {}
        self._type_map = type_map
        for prototype in prototypes:
            self.add(prototype)

    def __contains__(self, prototype):
        try:
            prototypes = self._prototypes[prototype.name]
        except KeyError:
            return False
        else:
            return prototype in prototypes

    def __iter__(self):
        for prototypes in itervalues(self._prototypes):
            for prototype in prototypes:
                yield prototype

    def __len__(self):

        return sum(imap(len, itervalues(self._prototypes)))