/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 breezy/intset.py

  • Committer: Jelmer Vernooij
  • Date: 2019-05-29 03:22:34 UTC
  • mfrom: (7303 work)
  • mto: This revision was merged to the branch mainline in revision 7306.
  • Revision ID: jelmer@jelmer.uk-20190529032234-mt3fuws8gq03tapi
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
        if values is not None:
77
77
            self.update(values)
78
78
 
79
 
 
80
79
    def __bool__(self):
81
80
        """IntSets are false if empty, otherwise True.
82
81
 
90
89
 
91
90
    __nonzero__ = __bool__
92
91
 
93
 
 
94
92
    def __len__(self):
95
93
        """Number of elements in set.
96
94
 
105
103
            v = v >> 1
106
104
        return c
107
105
 
108
 
 
109
106
    def __and__(self, other):
110
107
        """Set intersection.
111
108
 
123
120
            raise NotImplementedError(type(other))
124
121
        return IntSet(bitmask=(self._val & other._val))
125
122
 
126
 
 
127
123
    def __or__(self, other):
128
124
        """Set union.
129
125
 
135
131
            raise NotImplementedError(type(other))
136
132
        return IntSet(bitmask=(self._val | other._val))
137
133
 
138
 
 
139
134
    def __eq__(self, other):
140
135
        """Comparison.
141
136
 
147
142
        else:
148
143
            return False
149
144
 
150
 
 
151
145
    def __ne__(self, other):
152
146
        return not self.__eq__(other)
153
147
 
154
 
 
155
148
    def __contains__(self, i):
156
149
        return self._val & (1 << i)
157
150
 
158
 
 
159
151
    def __iter__(self):
160
152
        """Return contents of set.
161
153
 
173
165
            v = v >> 1
174
166
            o = o + 1
175
167
 
176
 
 
177
168
    def update(self, to_add):
178
169
        """Add all the values from the sequence or intset to_add"""
179
170
        if isinstance(to_add, IntSet):
182
173
            for i in to_add:
183
174
                self._val |= (1 << i)
184
175
 
185
 
 
186
176
    def add(self, to_add):
187
177
        self._val |= (1 << to_add)
188
178
 
189
 
 
190
179
    def remove(self, to_remove):
191
180
        """Remove one value from the set.
192
181
 
226
215
            return
227
216
        intersect = self._val & to_remove._val
228
217
        self._val ^= intersect
229