@@ -7,9 +7,6 @@ use core::hash::Hash;
7
7
use index_table:: { IndexTable , SmallIndex } ;
8
8
use std:: { borrow:: Borrow , hash:: BuildHasher , ops:: RangeBounds } ;
9
9
10
- #[ path = "test_map.rs" ]
11
- mod test_map;
12
-
13
10
/// A hash map that maintains the order of its elements.
14
11
#[ derive( Clone ) ]
15
12
pub struct StableMap < K , V , S , W =u32 > {
@@ -260,20 +257,14 @@ impl<K: Hash + Eq, V, S: BuildHasher, W: SmallIndex> StableMap<K, V, S, W> {
260
257
/// Removes the entry with the specified index from the set and returns its key and value, if it exists.
261
258
///
262
259
/// The last item is put in its place.
263
- pub fn swap_remove_index_full ( & mut self , index : usize ) -> Option < ( K , V ) > {
260
+ pub fn swap_remove_index ( & mut self , index : usize ) -> Option < ( K , V ) > {
264
261
let hash = self . build_hasher . hash_one ( & self . items . get ( index) ?. 0 ) ;
265
262
self . index_table
266
263
. find_entry ( hash, |i| i == index)
267
264
. unwrap ( )
268
265
. remove ( ) ;
269
266
Some ( self . swap_remove_finish ( index) )
270
267
}
271
- /// Removes the entry with the specified index from the set and returns its value, if it exists.
272
- ///
273
- /// The last item is put in its place.
274
- pub fn swap_remove_index ( & mut self , index : usize ) -> Option < V > {
275
- self . swap_remove_index_full ( index) . map ( |x| x. 1 )
276
- }
277
268
/// Removes all items for which `f` evaluates to `false`.
278
269
///
279
270
/// `f` is guaranteed to be called exactly once for each item and in order, and may mutate the values.
@@ -554,7 +545,7 @@ impl<K: Hash, V, S: BuildHasher, W: SmallIndex> OccupiedEntry<'_, K, V, S, W> {
554
545
}
555
546
556
547
impl < ' a , K , V , S , W : SmallIndex > Entry < ' a , K , V , S , W > {
557
- /// Returns a refernece to the key of the entry.
548
+ /// Returns a reference to the key of the entry.
558
549
pub fn key ( & self ) -> & K {
559
550
match self {
560
551
Entry :: Vacant ( entry) => entry. key ( ) ,
@@ -613,7 +604,7 @@ impl<'a, K, V, S, W: SmallIndex> Entry<'a, K, V, S, W> {
613
604
614
605
impl < K : Hash , V , S : BuildHasher , W : SmallIndex > StableMap < K , V , S , W > {
615
606
#[ cfg( test) ]
616
- fn check ( & self ) {
607
+ pub ( crate ) fn check ( & self ) {
617
608
assert ! ( self . index_table. len( ) == self . items. len( ) ) ;
618
609
for ( index, ( key, _) ) in self . items . iter ( ) . enumerate ( ) {
619
610
let hash = self . build_hasher . hash_one ( key) ;
0 commit comments