@@ -132,69 +132,69 @@ def __contains__(self, item):
132132 return item in self ._items [i :j ]
133133
134134 def index (self , item ):
135- ' Find the position of an item. Raise ValueError if not found.'
135+ " Find the position of an item. Raise ValueError if not found."
136136 k = self ._key (item )
137137 i = bisect_left (self ._keys , k )
138138 j = bisect_right (self ._keys , k )
139139 return self ._items [i :j ].index (item ) + i
140140
141141 def count (self , item ):
142- ' Return number of occurrences of item'
142+ " Return number of occurrences of item"
143143 k = self ._key (item )
144144 i = bisect_left (self ._keys , k )
145145 j = bisect_right (self ._keys , k )
146146 return self ._items [i :j ].count (item )
147147
148148 def insert (self , item ):
149- ' Insert a new item. If equal keys are found, add to the left'
149+ " Insert a new item. If equal keys are found, add to the left"
150150 k = self ._key (item )
151151 i = bisect_left (self ._keys , k )
152152 self ._keys .insert (i , k )
153153 self ._items .insert (i , item )
154154
155155 def insert_right (self , item ):
156- ' Insert a new item. If equal keys are found, add to the right'
156+ " Insert a new item. If equal keys are found, add to the right"
157157 k = self ._key (item )
158158 i = bisect_right (self ._keys , k )
159159 self ._keys .insert (i , k )
160160 self ._items .insert (i , item )
161161
162162 def remove (self , item ):
163- ' Remove first occurrence of item. Raise ValueError if not found'
163+ " Remove first occurrence of item. Raise ValueError if not found"
164164 i = self .index (item )
165165 del self ._keys [i ]
166166 del self ._items [i ]
167167
168168 def find (self , k ):
169- ' Return first item with a key == k. Raise ValueError if not found.'
169+ " Return first item with a key == k. Raise ValueError if not found."
170170 i = bisect_left (self ._keys , k )
171171 if i != len (self ) and self ._keys [i ] == k :
172172 return self ._items [i ]
173173 raise ValueError (f'No item found with key equal to: { k !r} ' )
174174
175175 def find_le (self , k ):
176- ' Return last item with a key <= k. Raise ValueError if not found.'
176+ " Return last item with a key <= k. Raise ValueError if not found."
177177 i = bisect_right (self ._keys , k )
178178 if i :
179179 return self ._items [i - 1 ]
180180 raise ValueError (f'No item found with key at or below: { k !r} ' )
181181
182182 def find_lt (self , k ):
183- ' Return last item with a key < k. Raise ValueError if not found.'
183+ " Return last item with a key < k. Raise ValueError if not found."
184184 i = bisect_left (self ._keys , k )
185185 if i :
186186 return self ._items [i - 1 ]
187187 raise ValueError (f'No item found with key below: { k !r} ' )
188188
189189 def find_ge (self , k ):
190- ' Return first item with a key >= equal to k. Raise ValueError if not found'
190+ " Return first item with a key >= equal to k. Raise ValueError if not found"
191191 i = bisect_left (self ._keys , k )
192192 if i != len (self ):
193193 return self ._items [i ]
194194 raise ValueError (f'No item found with key at or above: { k !r} ' )
195195
196196 def find_gt (self , k ):
197- ' Return first item with a key > k. Raise ValueError if not found'
197+ " Return first item with a key > k. Raise ValueError if not found"
198198 i = bisect_right (self ._keys , k )
199199 if i != len (self ):
200200 return self ._items [i ]
@@ -232,49 +232,49 @@ def __delitem__(self, index):
232232if __name__ == '__main__' :
233233
234234 def ve2no (f , * args ):
235- ' Convert ValueError result to -1'
235+ " Convert ValueError result to -1"
236236 try :
237237 return f (* args )
238238 except ValueError :
239239 return - 1
240240
241241 def slow_index (seq , k ):
242- ' Location of match or -1 if not found'
242+ " Location of match or -1 if not found"
243243 for i , item in enumerate (seq ):
244244 if item == k :
245245 return i
246246 return - 1
247247
248248 def slow_find (seq , k ):
249- ' First item with a key equal to k. -1 if not found'
249+ " First item with a key equal to k. -1 if not found"
250250 for item in seq :
251251 if item == k :
252252 return item
253253 return - 1
254254
255255 def slow_find_le (seq , k ):
256- ' Last item with a key less-than or equal to k.'
256+ " Last item with a key less-than or equal to k."
257257 for item in reversed (seq ):
258258 if item <= k :
259259 return item
260260 return - 1
261261
262262 def slow_find_lt (seq , k ):
263- ' Last item with a key less-than k.'
263+ " Last item with a key less-than k."
264264 for item in reversed (seq ):
265265 if item < k :
266266 return item
267267 return - 1
268268
269269 def slow_find_ge (seq , k ):
270- ' First item with a key-value greater-than or equal to k.'
270+ " First item with a key-value greater-than or equal to k."
271271 for item in seq :
272272 if item >= k :
273273 return item
274274 return - 1
275275
276276 def slow_find_gt (seq , k ):
277- ' First item with a key-value greater-than or equal to k.'
277+ " First item with a key-value greater-than or equal to k."
278278 for item in seq :
279279 if item > k :
280280 return item
0 commit comments