예제 #1
0
 def extend(self, objects):
     """
     Extends the list with the given `objects`.
     """
     if self.exhausted:
         self._collected_data.extend(objects)
     else:
         self._iterator = chain(self._iterator, objects)
예제 #2
0
 def extend(self, objects):
     """
     Extends the list with the given `objects`.
     """
     if self.exhausted:
         self._collected_data.extend(objects)
     else:
         self._iterator = chain(self._iterator, objects)
예제 #3
0
    def elements(self):
        """
        Iterator over the elements in the counter, repeating as many times as
        counted.

        >>> from brownie.datastructures import Counter
        >>> sorted(Counter('abcabc').elements())
        ['a', 'a', 'b', 'b', 'c', 'c']
        """
        return chain(*starmap(repeat, self.iteritems()))
예제 #4
0
 def __add__(self, other):
     if isinstance(other, (list, self.__class__)):
         return self.__class__(chain(self, other))
     raise TypeError("can't concatenate with non-list: {0}".format(other))
예제 #5
0
 def symmetric_difference(self, other):
     other = self.__class__(other)
     return self.__class__(chain(self - other, other - self))
예제 #6
0
 def __add__(self, other):
     if isinstance(other, (list, self.__class__)):
         return self.__class__(chain(self, other))
     raise TypeError("can't concatenate with non-list: {0}".format(other))
예제 #7
0
파일: sets.py 프로젝트: MiguelMoll/vFense
 def symmetric_difference(self, other):
     other = self.__class__(other)
     return self.__class__(chain(self - other, other - self))
예제 #8
0
def test_chain():
    list(chain([1, 2], [3, 4])) == [1, 2, 3, 4]
    list(chain.from_iterable([[1, 2], [3, 4]])) == [1, 2, 3, 4]
예제 #9
0
파일: itools.py 프로젝트: DocHoncho/brownie
def test_chain():
    Assert(list(chain([1, 2], [3, 4]))) == [1, 2, 3, 4]
    Assert(list(chain.from_iterable([[1, 2], [3, 4]]))) == [1, 2, 3, 4]
예제 #10
0
def test_chain():
    Assert(list(chain([1, 2], [3, 4]))) == [1, 2, 3, 4]
    Assert(list(chain.from_iterable([[1, 2], [3, 4]]))) == [1, 2, 3, 4]
예제 #11
0
파일: itools.py 프로젝트: MiguelMoll/vFense
def test_chain():
    list(chain([1, 2], [3, 4])) == [1, 2, 3, 4]
    list(chain.from_iterable([[1, 2], [3, 4]])) == [1, 2, 3, 4]