/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: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

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
 
 
19
17
# Author: Martin Pool <mbp@canonical.com>
20
18
 
21
19
 
66
64
    """
67
65
    __slots__ = ['_val']
68
66
 
69
 
    def __init__(self, values=None, bitmask=0):
 
67
    def __init__(self, values=None, bitmask=0L):
70
68
        """Create a new intset.
71
69
 
72
70
        values
77
75
            self.update(values)
78
76
 
79
77
 
80
 
    def __bool__(self):
 
78
    def __nonzero__(self):
81
79
        """IntSets are false if empty, otherwise True.
82
80
 
83
81
        >>> bool(IntSet())
88
86
        """
89
87
        return bool(self._val)
90
88
 
91
 
    __nonzero__ = __bool__
92
 
 
93
89
 
94
90
    def __len__(self):
95
91
        """Number of elements in set.
153
149
 
154
150
 
155
151
    def __contains__(self, i):
156
 
        return self._val & (1 << i)
 
152
        return self._val & (1L << i)
157
153
 
158
154
 
159
155
    def __iter__(self):
180
176
            self._val |= to_add._val
181
177
        else:
182
178
            for i in to_add:
183
 
                self._val |= (1 << i)
 
179
                self._val |= (1L << i)
184
180
 
185
181
 
186
182
    def add(self, to_add):
187
 
        self._val |= (1 << to_add)
 
183
        self._val |= (1L << to_add)
188
184
 
189
185
 
190
186
    def remove(self, to_remove):
204
200
        >>> not a
205
201
        True
206
202
        """
207
 
        m = 1 << to_remove
 
203
        m = 1L << to_remove
208
204
        if not self._val & m:
209
205
            raise KeyError(to_remove)
210
206
        self._val ^= m