~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/intset.py

  • Committer: Martin Pool
  • Date: 2005-09-30 05:56:05 UTC
  • mto: (1185.14.2)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: mbp@sourcefrog.net-20050930055605-a2c534529b392a7d
- fix upgrade for transport changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005 Canonical Ltd
2
 
#
 
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
#
 
7
 
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
#
 
12
 
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
71
71
            If specified, an initial collection of values.
72
72
        """
73
73
        self._val = bitmask
74
 
        if values is not None:
 
74
        if values != None:
75
75
            self.update(values)
76
76
 
77
77
 
208
208
        if not self._val & m:
209
209
            raise KeyError(to_remove)
210
210
        self._val ^= m
211
 
 
212
 
    def set_remove(self, to_remove):
213
 
        """Remove all values that exist in to_remove.
214
 
 
215
 
        >>> a = IntSet(range(10))
216
 
        >>> b = IntSet([2,3,4,7,12])
217
 
        >>> a.set_remove(b)
218
 
        >>> list(a)
219
 
        [0, 1, 5, 6, 8, 9]
220
 
        >>> a.set_remove([1,2,5])
221
 
        >>> list(a)
222
 
        [0, 6, 8, 9]
223
 
        """
224
 
        if not isinstance(to_remove, IntSet):
225
 
            self.set_remove(IntSet(to_remove))
226
 
            return
227
 
        intersect = self._val & to_remove._val
228
 
        self._val ^= intersect
229