@@ -349,6 +349,7 @@ impl<T, S> IndexSet<T, S>
349
349
/// FIXME Same as .swap_take
350
350
///
351
351
/// Computes in **O(1)** time (average).
352
+ #[ deprecated( note = "use `swap_take` or `shift_take`" ) ]
352
353
pub fn take < Q : ?Sized > ( & mut self , value : & Q ) -> Option < T >
353
354
where Q : Hash + Equivalent < T > ,
354
355
{
@@ -371,6 +372,22 @@ impl<T, S> IndexSet<T, S>
371
372
self . map . swap_remove_full ( value) . map ( |( _, x, ( ) ) | x)
372
373
}
373
374
375
+ /// Removes and returns the value in the set, if any, that is equal to the
376
+ /// given one.
377
+ ///
378
+ /// Like `Vec::remove`, the value is removed by shifting all of the
379
+ /// elements that follow it, preserving their relative order.
380
+ /// **This perturbs the index of all of those elements!**
381
+ ///
382
+ /// Return `None` if `value` was not in the set.
383
+ ///
384
+ /// Computes in **O(n)** time (average).
385
+ pub fn shift_take < Q : ?Sized > ( & mut self , value : & Q ) -> Option < T >
386
+ where Q : Hash + Equivalent < T > ,
387
+ {
388
+ self . map . shift_remove_full ( value) . map ( |( _, x, ( ) ) | x)
389
+ }
390
+
374
391
/// Remove the value from the set return it and the index it had.
375
392
///
376
393
/// Like `Vec::swap_remove`, the value is removed by swapping it with the
0 commit comments