예제 #1
0
	def __ixor__(self, other):
		for key, value in other.iteritems():
			if key in self:
				self[key] ^= value
			else:
				self[key] = _shallowcopy(value)
		return self
예제 #2
0
 def __ixor__(self, other):
     for key, value in other.iteritems():
         if key in self:
             self[key] ^= value
         else:
             self[key] = _shallowcopy(value)
     return self
예제 #3
0
	def __ior__(self, other):
		for key, value in six.iteritems(other):
			if key in self:
				self[key] |= value
			else:
				self[key] = _shallowcopy(value)
		return self
예제 #4
0
    def extend(self, other):
        """
		Appends the segmentlists from other to the corresponding
		segmentlists in self, adding new segmentslists to self as
		needed.
		"""
        for key, value in other.iteritems():
            if key not in self:
                self[key] = _shallowcopy(value)
            else:
                self[key].extend(value)
예제 #5
0
	def extend(self, other):
		"""
		Appends the segmentlists from other to the corresponding
		segmentlists in self, adding new segmentslists to self as
		needed.
		"""
		for key, value in other.iteritems():
			if key not in self:
				self[key] = _shallowcopy(value)
			else:
				self[key].extend(value)
예제 #6
0
    def union(self, keys):
        """
		Return the union of the segmentlists associated with the
		keys in keys.
		"""
        keys = set(keys)
        if not keys:
            return segmentlist()
        seglist = _shallowcopy(self[keys.pop()])
        for key in keys:
            seglist |= self[key]
        return seglist
예제 #7
0
	def union(self, keys):
		"""
		Return the union of the segmentlists associated with the
		keys in keys.
		"""
		keys = set(keys)
		if not keys:
			return segmentlist()
		seglist = _shallowcopy(self[keys.pop()])
		for key in keys:
			seglist |= self[key]
		return seglist
예제 #8
0
    def extract_common(self, keys):
        """
		Return a new segmentlistdict containing only those
		segmentlists associated with the keys in keys, with each
		set to their mutual intersection.  The offsets are
		preserved.
		"""
        keys = set(keys)
        new = self.__class__()
        intersection = self.intersection(keys)
        for key in keys:
            dict.__setitem__(new, key, _shallowcopy(intersection))
            dict.__setitem__(new.offsets, key, self.offsets[key])
        return new
예제 #9
0
	def extract_common(self, keys):
		"""
		Return a new segmentlistdict containing only those
		segmentlists associated with the keys in keys, with each
		set to their mutual intersection.  The offsets are
		preserved.
		"""
		keys = set(keys)
		new = self.__class__()
		intersection = self.intersection(keys)
		for key in keys:
			dict.__setitem__(new, key, _shallowcopy(intersection))
			dict.__setitem__(new.offsets, key, self.offsets[key])
		return new
예제 #10
0
    def copy(self, keys=None):
        """
		Return a copy of the segmentlistdict object.  The return
		value is a new object with a new offsets attribute, with
		references to the original keys, and shallow copies of the
		segment lists.  Modifications made to the offset dictionary
		or segmentlists in the object returned by this method will
		not affect the original, but without using much memory
		until such modifications are made.  If the optional keys
		argument is not None, then should be an iterable of keys
		and only those segmentlists will be copied (KeyError is
		raised if any of those keys are not in the
		segmentlistdict).

		More details.  There are two "built-in" ways to create a
		copy of a segmentlist object.  The first is to initialize a
		new object from an existing one with

		>>> old = segmentlistdict()
		>>> new = segmentlistdict(old)

		This creates a copy of the dictionary, but not of its
		contents.  That is, this creates new with references to the
		segmentlists in old, therefore changes to the segmentlists
		in either new or old are reflected in both.  The second
		method is

		>>> new = old.copy()

		This creates a copy of the dictionary and of the
		segmentlists, but with references to the segment objects in
		the original segmentlists.  Since segments are immutable,
		this effectively creates a completely independent working
		copy but without the memory cost of a full duplication of
		the data.
		"""
        if keys is None:
            keys = self
        new = self.__class__()
        for key in keys:
            new[key] = _shallowcopy(self[key])
            dict.__setitem__(new.offsets, key, self.offsets[key])
        return new
예제 #11
0
	def copy(self, keys = None):
		"""
		Return a copy of the segmentlistdict object.  The return
		value is a new object with a new offsets attribute, with
		references to the original keys, and shallow copies of the
		segment lists.  Modifications made to the offset dictionary
		or segmentlists in the object returned by this method will
		not affect the original, but without using much memory
		until such modifications are made.  If the optional keys
		argument is not None, then should be an iterable of keys
		and only those segmentlists will be copied (KeyError is
		raised if any of those keys are not in the
		segmentlistdict).

		More details.  There are two "built-in" ways to create a
		copy of a segmentlist object.  The first is to initialize a
		new object from an existing one with

		>>> old = segmentlistdict()
		>>> new = segmentlistdict(old)

		This creates a copy of the dictionary, but not of its
		contents.  That is, this creates new with references to the
		segmentlists in old, therefore changes to the segmentlists
		in either new or old are reflected in both.  The second
		method is

		>>> new = old.copy()

		This creates a copy of the dictionary and of the
		segmentlists, but with references to the segment objects in
		the original segmentlists.  Since segments are immutable,
		this effectively creates a completely independent working
		copy but without the memory cost of a full duplication of
		the data.
		"""
		if keys is None:
			keys = self
		new = self.__class__()
		for key in keys:
			new[key] = _shallowcopy(self[key])
			dict.__setitem__(new.offsets, key, self.offsets[key])
		return new