/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/intset.py

  • Committer: Jelmer Vernooij
  • Date: 2017-02-05 23:17:36 UTC
  • mto: (6621.2.2 py3)
  • mto: This revision was merged to the branch mainline in revision 6624.
  • Revision ID: jelmer@jelmer.uk-20170205231736-r23gq807d70rbd2c
Run 2to3 execfile fixer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
# Author: Martin Pool <mbp@canonical.com>
18
20
 
19
21
 
64
66
    """
65
67
    __slots__ = ['_val']
66
68
 
67
 
    def __init__(self, values=None, bitmask=0L):
 
69
    def __init__(self, values=None, bitmask=0):
68
70
        """Create a new intset.
69
71
 
70
72
        values
75
77
            self.update(values)
76
78
 
77
79
 
78
 
    def __nonzero__(self):
 
80
    def __bool__(self):
79
81
        """IntSets are false if empty, otherwise True.
80
82
 
81
83
        >>> bool(IntSet())
149
151
 
150
152
 
151
153
    def __contains__(self, i):
152
 
        return self._val & (1L << i)
 
154
        return self._val & (1 << i)
153
155
 
154
156
 
155
157
    def __iter__(self):
176
178
            self._val |= to_add._val
177
179
        else:
178
180
            for i in to_add:
179
 
                self._val |= (1L << i)
 
181
                self._val |= (1 << i)
180
182
 
181
183
 
182
184
    def add(self, to_add):
183
 
        self._val |= (1L << to_add)
 
185
        self._val |= (1 << to_add)
184
186
 
185
187
 
186
188
    def remove(self, to_remove):
200
202
        >>> not a
201
203
        True
202
204
        """
203
 
        m = 1L << to_remove
 
205
        m = 1 << to_remove
204
206
        if not self._val & m:
205
207
            raise KeyError(to_remove)
206
208
        self._val ^= m