�
���Zc�����������@@��s����d��d�l��m�Z�y�d��d�l�m�Z�Wn��e�k
�r��d��d�l�m�Z�d��d�l�m�Z�d��d�l	�m
�Z
�m�Z�d�e�f�d�������YZ�e
�d�k�r��d��d	�l�Z�e�j����GHn��n�Xd	�S(
���i����(���t���absolute_import(���t���Counter(���t
���itemgetter(���t���nlargest(���t���repeatt���ifilterR���c�����������B@��s����e��Z�d��Z�d�d���Z�d����Z�d�d���Z�d����Z�e�d�d�����Z	�d�d���Z
�d�d���Z�d����Z�d	����Z
�d
����Z�d����Z�d����Z�d
����Z�d����Z�d����Z�RS(���s'��Dict subclass for counting hashable items.  Sometimes called a bag
        or multiset.  Elements are stored as dictionary keys and their counts
        are stored as dictionary values.

        >>> c = Counter('abcdeabcdabcaba')  # count elements from a string

        >>> c.most_common(3)                # three most common elements
        [('a', 5), ('b', 4), ('c', 3)]
        >>> sorted(c)                       # list all unique elements
        ['a', 'b', 'c', 'd', 'e']
        >>> ''.join(sorted(c.elements()))   # list elements with repetitions
        'aaaaabbbbcccdde'
        >>> sum(c.values())                 # total of all counts
        15

        >>> c['a']                          # count of letter 'a'
        5
        >>> for elem in 'shazam':           # update counts from an iterable
        ...     c[elem] += 1                # by adding 1 to each element's count
        >>> c['a']                          # now there are seven 'a'
        7
        >>> del c['b']                      # remove all 'b'
        >>> c['b']                          # now there are zero 'b'
        0

        >>> d = Counter('simsalabim')       # make another counter
        >>> c.update(d)                     # add in the second counter
        >>> c['a']                          # now there are nine 'a'
        9

        >>> c.clear()                       # empty the counter
        >>> c
        Counter()

        Note:  If a count is set to zero or reduced to zero, it will remain
        in the counter until the entry is deleted or the counter is cleared:

        >>> c = Counter('aaabbc')
        >>> c['b'] -= 2                     # reduce the count of 'b' by two
        >>> c.most_common()                 # 'b' is still in, but its count is zero
        [('a', 3), ('c', 1), ('b', 0)]

        c���������K@��s���|��j��|�|���d�S(���s%��Create a new, empty Counter object.  And if given, count elements
            from an input iterable.  Or, initialize the count from another mapping
            of elements to their counts.

            >>> c = Counter()                           # a new, empty counter
            >>> c = Counter('gallahad')                 # a new counter from an iterable
            >>> c = Counter({'a': 4, 'b': 2})           # a new counter from a mapping
            >>> c = Counter(a=4, b=2)                   # a new counter from keyword args

            N(���t���update(���t���selft���iterablet���kwds(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���__init__V���s����c���������C@��s���d�S(���s1���The count of elements not in the Counter is zero.i����(����(���R���t���key(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���__missing__c���s����c���������C@��sM���|�d�k�r.�t�|��j����d�t�d���d�t��St�|�|��j����d�t�d����S(���s���List the n most common elements and their counts from the most
            common to the least.  If n is None, then list all element counts.

            >>> Counter('abcdeabcdabcaba').most_common(3)
            [('a', 5), ('b', 4), ('c', 3)]

            R���i���t���reverseN(���t���Nonet���sortedt	���iteritemsR���t���TrueR���(���R���t���n(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���most_commonh���s����	"c���������c@��s@���x9�|��j�����D]+�\�}�}�x�t�d�|���D]�}�|�Vq)�Wq
�Wd�S(���s���Iterator over elements repeating each as many times as its count.

            >>> c = Counter('ABCABC')
            >>> sorted(c.elements())
            ['A', 'A', 'B', 'B', 'C', 'C']

            # Knuth's example for prime factors of 1836:  2**2 * 3**3 * 17**1
            >>> prime_factors = Counter({2: 2, 3: 3, 17: 1})
            >>> product = 1
            >>> for factor in prime_factors.elements():     # loop over factors
            ...     product *= factor                       # and multiply them
            >>> product
            1836

            Note, if an element's count has been set to zero or is a negative
            number, elements() will ignore it.

            N(���R���R���R���(���R���t���elemt���countt���_(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���elementsu���s����c���������C@��s���t��d�����d��S(���Ns@���Counter.fromkeys() is undefined.  Use Counter(iterable) instead.(���t���NotImplementedError(���t���clsR���t���v(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���fromkeys����s����c���������K@��s����|�d�k	�r��t�|�d���rt�|��ra�|��j�}�xD�|�j����D]#�\�}�}�|�|�d���|�|��|�<q7�Wq��t�j�|��|���q��|��j�}�x(�|�D]�}�|�|�d���d�|��|�<q��Wn��|�r��|��j�|���n��d�S(���s���Like dict.update() but add counts instead of replacing them.

            Source can be an iterable, a dictionary, or another Counter instance.

            >>> c = Counter('which')
            >>> c.update('witch')           # add elements from another iterable
            >>> d = Counter('watch')
            >>> c.update(d)                 # add elements from another counter
            >>> c['h']                      # four 'h' in which, witch, and watch
            4

            R���i����i���N(���R���t���hasattrt���getR���t���dictR���(���R���R���R	���t���self_getR���R���(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyR�������s����		
c���������K@��sd���t��|�d���r?�xN�|�j����D]�\�}�}�|��|�c�|�8<q�Wn!�x�|�D]�}�|��|�c�d�8<qF�Wd�S(���s���Like dict.update() but subtracts counts instead of replacing them.
            Counts can be reduced below zero.  Both the inputs and outputs are
            allowed to contain zero and negative counts.

            Source can be an iterable, a dictionary, or another Counter instance.

            >>> c = Counter('which')
            >>> c.subtract('witch')             # subtract elements from another iterable
            >>> c.subtract(Counter('watch'))    # subtract elements from another counter
            >>> c['h']                          # 2 in which, minus 1 in witch, minus 1 in watch
            0
            >>> c['w']                          # 1 in which, minus 1 in witch, minus 1 in watch
            -1

            R���i���N(���R���R���(���R���R���R	���R���R���(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���subtract����s
����
c���������C@��s
���|��j��|����S(���s���Return a shallow copy.(���t	���__class__(���R���(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���copy����s����c���������C@��s���|��j��t�|����f�f�S(���N(���R!���R���(���R���(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt
���__reduce__����s����c���������C@��s#���|�|��k�r�t��j�|��|���n��d�S(���sG���Like dict.__delitem__() but does not raise KeyError for missing values.N(���R���t���__delitem__(���R���R���(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyR$�������s����c���������C@��sI���|��s�d�|��j��j�Sd�j�t�d�j�|��j��������}�d�|��j��j�|�f�S(���Ns���%s()s���, s���%r: %rs���%s({%s})(���R!���t���__name__t���joint���mapt���__mod__R���(���R���t���items(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���__repr__����s����!c���������C@��sl���t��|�t���s�t�St����}�xI�t�|����t�|���BD]1�}�|��|�|�|�}�|�d�k�r3�|�|�|�<q3�q3�W|�S(���s����Add counts from two counters.

            >>> Counter('abbb') + Counter('bcc')
            Counter({'b': 4, 'c': 2, 'a': 1})

            i����(���t
���isinstanceR���t���NotImplementedt���set(���R���t���othert���resultR���t���newcount(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���__add__����s����	c���������C@��sl���t��|�t���s�t�St����}�xI�t�|����t�|���BD]1�}�|��|�|�|�}�|�d�k�r3�|�|�|�<q3�q3�W|�S(���s���� Subtract count, but keep only results with positive counts.

            >>> Counter('abbbc') - Counter('bccd')
            Counter({'b': 2, 'a': 1})

            i����(���R+���R���R,���R-���(���R���R.���R/���R���R0���(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���__sub__����s����	c���������C@��sw���t��|�t���s�t�St�}�t����}�xN�t�|����t�|���BD]6�}�|�|��|�|�|���}�|�d�k�r9�|�|�|�<q9�q9�W|�S(���s����Union is the maximum of value in either of the input counters.

            >>> Counter('abbb') | Counter('bcc')
            Counter({'b': 3, 'c': 2, 'a': 1})

            i����(���R+���R���R,���t���maxR-���(���R���R.���t���_maxR/���R���R0���(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���__or__��s����	c���������C@��s����t��|�t���s�t�St�}�t����}�t�|����t�|���k��rJ�|�|��}��}�n��xJ�t�|��j�|���D]6�}�|�|��|�|�|���}�|�d�k�r]�|�|�|�<q]�q]�W|�S(���s���� Intersection is the minimum of corresponding counts.

            >>> Counter('abbb') & Counter('bcc')
            Counter({'b': 1})

            i����(���R+���R���R,���t���mint���lenR���t���__contains__(���R���R.���t���_minR/���R���R0���(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���__and__��s����	N(���R%���t
���__module__t���__doc__R���R
���R���R���R���t���classmethodR���R���R ���R"���R#���R$���R*���R1���R2���R5���R:���(����(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyR���#���s"���+
	
	#							t���__main__N(���t
���__future__R����t���collectionsR���t���ImportErrort���operatorR���t���heapqR���t	���itertoolsR���R���R���R%���t���doctestt���testmod(����(����(����sw���/home/vagrant/ruby-gnome2/gobject-introspection/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyt���<module>���s���
��