1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! A simple map based on a vector for small integer keys. Space requirements
12 //! are O(highest integer key).
14 #![allow(missing_doc)]
18 use core::default::Default;
21 use core::iter::{Enumerate, FilterMap};
22 use core::mem::replace;
24 use {Mutable, Map, MutableMap, MutableSeq};
30 /// A map optimized for small integer keys.
35 /// use std::collections::SmallIntMap;
37 /// let mut months = SmallIntMap::new();
38 /// months.insert(1, "Jan");
39 /// months.insert(2, "Feb");
40 /// months.insert(3, "Mar");
42 /// if !months.contains_key(&12) {
43 /// println!("The end is near!");
46 /// assert_eq!(months.find(&1), Some(&"Jan"));
48 /// match months.find_mut(&3) {
49 /// Some(value) => *value = "Venus",
53 /// assert_eq!(months.find(&3), Some(&"Venus"));
55 /// // Print out all months
56 /// for (key, value) in months.iter() {
57 /// println!("month {} is {}", key, value);
61 /// assert!(months.is_empty());
63 #[deriving(PartialEq, Eq)]
64 pub struct SmallIntMap<T> {
68 impl<V> Collection for SmallIntMap<V> {
69 /// Returns the number of elements in the map.
70 fn len(&self) -> uint {
71 self.v.iter().filter(|elt| elt.is_some()).count()
74 /// Returns`true` if there are no elements in the map.
75 fn is_empty(&self) -> bool {
76 self.v.iter().all(|elt| elt.is_none())
80 impl<V> Mutable for SmallIntMap<V> {
81 /// Clears the map, removing all key-value pairs.
82 fn clear(&mut self) { self.v.clear() }
85 impl<V> Map<uint, V> for SmallIntMap<V> {
86 /// Returns a reference to the value corresponding to the key.
87 fn find<'a>(&'a self, key: &uint) -> Option<&'a V> {
88 if *key < self.v.len() {
90 Some(ref value) => Some(value),
99 impl<V> MutableMap<uint, V> for SmallIntMap<V> {
100 /// Returns a mutable reference to the value corresponding to the key.
101 fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut V> {
102 if *key < self.v.len() {
103 match *self.v.get_mut(*key) {
104 Some(ref mut value) => Some(value),
112 /// Inserts a key-value pair into the map. An existing value for a
113 /// key is replaced by the new value. Returns `true` if the key did
114 /// not already exist in the map.
115 fn insert(&mut self, key: uint, value: V) -> bool {
116 let exists = self.contains_key(&key);
117 let len = self.v.len();
119 self.v.grow_fn(key - len + 1, |_| None);
121 *self.v.get_mut(key) = Some(value);
125 /// Removes a key-value pair from the map. Returns `true` if the key
126 /// was present in the map.
127 fn remove(&mut self, key: &uint) -> bool {
128 self.pop(key).is_some()
131 /// Inserts a key-value pair into the map. If the key already had a value
132 /// present in the map, that value is returned. Otherwise `None` is returned.
133 fn swap(&mut self, key: uint, value: V) -> Option<V> {
134 match self.find_mut(&key) {
135 Some(loc) => { return Some(replace(loc, value)); }
138 self.insert(key, value);
142 /// Removes a key from the map, returning the value at the key if the key
143 /// was previously in the map.
144 fn pop(&mut self, key: &uint) -> Option<V> {
145 if *key >= self.v.len() {
148 self.v.get_mut(*key).take()
152 impl<V> Default for SmallIntMap<V> {
154 fn default() -> SmallIntMap<V> { SmallIntMap::new() }
157 impl<V:Clone> Clone for SmallIntMap<V> {
159 fn clone(&self) -> SmallIntMap<V> {
160 SmallIntMap { v: self.v.clone() }
164 fn clone_from(&mut self, source: &SmallIntMap<V>) {
165 self.v.reserve(source.v.len());
166 for (i, w) in self.v.iter_mut().enumerate() {
167 *w = source.v[i].clone();
172 impl <S: hash::Writer, T: Hash<S>> Hash<S> for SmallIntMap<T> {
173 fn hash(&self, state: &mut S) {
178 impl<V> SmallIntMap<V> {
179 /// Creates an empty `SmallIntMap`.
184 /// use std::collections::SmallIntMap;
185 /// let mut map: SmallIntMap<&str> = SmallIntMap::new();
187 pub fn new() -> SmallIntMap<V> { SmallIntMap{v: vec!()} }
189 /// Creates an empty `SmallIntMap` with space for at least `capacity`
190 /// elements before resizing.
195 /// use std::collections::SmallIntMap;
196 /// let mut map: SmallIntMap<&str> = SmallIntMap::with_capacity(10);
198 pub fn with_capacity(capacity: uint) -> SmallIntMap<V> {
199 SmallIntMap { v: Vec::with_capacity(capacity) }
202 /// Retrieves a value for the given key.
203 /// See [`find`](../trait.Map.html#tymethod.find) for a non-failing alternative.
207 /// Fails if the key is not present.
212 /// #![allow(deprecated)]
214 /// use std::collections::SmallIntMap;
216 /// let mut map = SmallIntMap::new();
217 /// map.insert(1, "a");
218 /// assert_eq!(map.get(&1), &"a");
220 #[deprecated = "prefer using indexing, e.g., map[0]"]
221 pub fn get<'a>(&'a self, key: &uint) -> &'a V {
222 self.find(key).expect("key not present")
225 /// Returns an iterator visiting all keys in ascending order by the keys.
226 /// The iterator's element type is `uint`.
227 pub fn keys<'r>(&'r self) -> Keys<'r, V> {
228 self.iter().map(|(k, _v)| k)
231 /// Returns an iterator visiting all values in ascending order by the keys.
232 /// The iterator's element type is `&'r V`.
233 pub fn values<'r>(&'r self) -> Values<'r, V> {
234 self.iter().map(|(_k, v)| v)
237 /// Returns an iterator visiting all key-value pairs in ascending order by the keys.
238 /// The iterator's element type is `(uint, &'r V)`.
243 /// use std::collections::SmallIntMap;
245 /// let mut map = SmallIntMap::new();
246 /// map.insert(1, "a");
247 /// map.insert(3, "c");
248 /// map.insert(2, "b");
250 /// // Print `1: a` then `2: b` then `3: c`
251 /// for (key, value) in map.iter() {
252 /// println!("{}: {}", key, value);
255 pub fn iter<'r>(&'r self) -> Entries<'r, V> {
263 /// Deprecated: use `iter_mut`
264 #[deprecated = "use iter_mut"]
265 pub fn mut_iter<'r>(&'r mut self) -> MutEntries<'r, V> {
269 /// Returns an iterator visiting all key-value pairs in ascending order by the keys,
270 /// with mutable references to the values.
271 /// The iterator's element type is `(uint, &'r mut V)`.
276 /// use std::collections::SmallIntMap;
278 /// let mut map = SmallIntMap::new();
279 /// map.insert(1, "a");
280 /// map.insert(2, "b");
281 /// map.insert(3, "c");
283 /// for (key, value) in map.iter_mut() {
287 /// for (key, value) in map.iter() {
288 /// assert_eq!(value, &"x");
291 pub fn iter_mut<'r>(&'r mut self) -> MutEntries<'r, V> {
295 iter: self.v.iter_mut()
299 /// Deprecated: use `into_iter` instead.
300 #[deprecated = "use into_iter"]
301 pub fn move_iter(&mut self)
302 -> FilterMap<(uint, Option<V>), (uint, V),
303 Enumerate<vec::MoveItems<Option<V>>>> {
307 /// Returns an iterator visiting all key-value pairs in ascending order by
308 /// the keys, emptying (but not consuming) the original `SmallIntMap`.
309 /// The iterator's element type is `(uint, &'r V)`.
314 /// use std::collections::SmallIntMap;
316 /// let mut map = SmallIntMap::new();
317 /// map.insert(1, "a");
318 /// map.insert(3, "c");
319 /// map.insert(2, "b");
321 /// // Not possible with .iter()
322 /// let vec: Vec<(uint, &str)> = map.into_iter().collect();
324 /// assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]);
326 pub fn into_iter(&mut self)
327 -> FilterMap<(uint, Option<V>), (uint, V),
328 Enumerate<vec::MoveItems<Option<V>>>>
330 let values = replace(&mut self.v, vec!());
331 values.into_iter().enumerate().filter_map(|(i, v)| {
337 impl<V:Clone> SmallIntMap<V> {
338 /// Updates a value in the map. If the key already exists in the map,
339 /// modifies the value with `ff` taking `oldval, newval`.
340 /// Otherwise, sets the value to `newval`.
341 /// Returns `true` if the key did not already exist in the map.
346 /// use std::collections::SmallIntMap;
348 /// let mut map = SmallIntMap::new();
350 /// // Key does not exist, will do a simple insert
351 /// assert!(map.update(1, vec![1i, 2], |old, new| old.append(new.as_slice())));
352 /// assert_eq!(map[1], vec![1i, 2]);
354 /// // Key exists, update the value
355 /// assert!(!map.update(1, vec![3i, 4], |old, new| old.append(new.as_slice())));
356 /// assert_eq!(map[1], vec![1i, 2, 3, 4]);
358 pub fn update(&mut self, key: uint, newval: V, ff: |V, V| -> V) -> bool {
359 self.update_with_key(key, newval, |_k, v, v1| ff(v,v1))
362 /// Updates a value in the map. If the key already exists in the map,
363 /// modifies the value with `ff` taking `key, oldval, newval`.
364 /// Otherwise, sets the value to `newval`.
365 /// Returns `true` if the key did not already exist in the map.
370 /// use std::collections::SmallIntMap;
372 /// let mut map = SmallIntMap::new();
374 /// // Key does not exist, will do a simple insert
375 /// assert!(map.update_with_key(7, 10, |key, old, new| (old + new) % key));
376 /// assert_eq!(map[7], 10);
378 /// // Key exists, update the value
379 /// assert!(!map.update_with_key(7, 20, |key, old, new| (old + new) % key));
380 /// assert_eq!(map[7], 2);
382 pub fn update_with_key(&mut self,
385 ff: |uint, V, V| -> V)
387 let new_val = match self.find(&key) {
389 Some(orig) => ff(key, (*orig).clone(), val)
391 self.insert(key, new_val)
395 impl<V: PartialOrd> PartialOrd for SmallIntMap<V> {
397 fn partial_cmp(&self, other: &SmallIntMap<V>) -> Option<Ordering> {
398 iter::order::partial_cmp(self.iter(), other.iter())
402 impl<V: Ord> Ord for SmallIntMap<V> {
404 fn cmp(&self, other: &SmallIntMap<V>) -> Ordering {
405 iter::order::cmp(self.iter(), other.iter())
409 impl<V: fmt::Show> fmt::Show for SmallIntMap<V> {
410 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
411 try!(write!(f, "{{"));
413 for (i, (k, v)) in self.iter().enumerate() {
414 if i != 0 { try!(write!(f, ", ")); }
415 try!(write!(f, "{}: {}", k, *v));
422 impl<V> FromIterator<(uint, V)> for SmallIntMap<V> {
423 fn from_iter<Iter: Iterator<(uint, V)>>(iter: Iter) -> SmallIntMap<V> {
424 let mut map = SmallIntMap::new();
430 impl<V> Extendable<(uint, V)> for SmallIntMap<V> {
431 fn extend<Iter: Iterator<(uint, V)>>(&mut self, mut iter: Iter) {
438 impl<V> Index<uint, V> for SmallIntMap<V> {
441 fn index<'a>(&'a self, i: &uint) -> &'a V {
446 // FIXME(#12825) Indexing will always try IndexMut first and that causes issues.
447 /*impl<V> IndexMut<uint, V> for SmallIntMap<V> {
449 fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut V {
450 self.find_mut(i).expect("key not present")
454 macro_rules! iterator {
455 (impl $name:ident -> $elem:ty, $getter:ident) => {
456 impl<'a, T> Iterator<$elem> for $name<'a, T> {
458 fn next(&mut self) -> Option<$elem> {
459 while self.front < self.back {
460 match self.iter.next() {
463 let index = self.front;
465 return Some((index, elem. $getter ()));
476 fn size_hint(&self) -> (uint, Option<uint>) {
477 (0, Some(self.back - self.front))
483 macro_rules! double_ended_iterator {
484 (impl $name:ident -> $elem:ty, $getter:ident) => {
485 impl<'a, T> DoubleEndedIterator<$elem> for $name<'a, T> {
487 fn next_back(&mut self) -> Option<$elem> {
488 while self.front < self.back {
489 match self.iter.next_back() {
493 return Some((self.back, elem. $getter ()));
506 /// Forward iterator over a map.
507 pub struct Entries<'a, T:'a> {
510 iter: slice::Items<'a, Option<T>>
513 iterator!(impl Entries -> (uint, &'a T), get_ref)
514 double_ended_iterator!(impl Entries -> (uint, &'a T), get_ref)
516 /// Forward iterator over the key-value pairs of a map, with the
517 /// values being mutable.
518 pub struct MutEntries<'a, T:'a> {
521 iter: slice::MutItems<'a, Option<T>>
524 iterator!(impl MutEntries -> (uint, &'a mut T), get_mut_ref)
525 double_ended_iterator!(impl MutEntries -> (uint, &'a mut T), get_mut_ref)
527 /// Forward iterator over the keys of a map
528 pub type Keys<'a, T> =
529 iter::Map<'static, (uint, &'a T), uint, Entries<'a, T>>;
531 /// Forward iterator over the values of a map
532 pub type Values<'a, T> =
533 iter::Map<'static, (uint, &'a T), &'a T, Entries<'a, T>>;
541 use {Map, MutableMap, Mutable, MutableSeq};
542 use super::SmallIntMap;
546 let mut m = SmallIntMap::new();
547 assert!(m.insert(1, 12i));
548 assert!(m.insert(2, 8));
549 assert!(m.insert(5, 14));
551 match m.find_mut(&5) {
552 None => fail!(), Some(x) => *x = new
554 assert_eq!(m.find(&5), Some(&new));
559 let mut map = SmallIntMap::new();
560 assert_eq!(map.len(), 0);
561 assert!(map.is_empty());
562 assert!(map.insert(5, 20i));
563 assert_eq!(map.len(), 1);
564 assert!(!map.is_empty());
565 assert!(map.insert(11, 12));
566 assert_eq!(map.len(), 2);
567 assert!(!map.is_empty());
568 assert!(map.insert(14, 22));
569 assert_eq!(map.len(), 3);
570 assert!(!map.is_empty());
575 let mut map = SmallIntMap::new();
576 assert!(map.insert(5, 20i));
577 assert!(map.insert(11, 12));
578 assert!(map.insert(14, 22));
580 assert!(map.is_empty());
581 assert!(map.find(&5).is_none());
582 assert!(map.find(&11).is_none());
583 assert!(map.find(&14).is_none());
587 fn test_insert_with_key() {
588 let mut map = SmallIntMap::new();
590 // given a new key, initialize it with this new count,
591 // given an existing key, add more to its count
592 fn add_more_to_count(_k: uint, v0: uint, v1: uint) -> uint {
596 fn add_more_to_count_simple(v0: uint, v1: uint) -> uint {
601 map.update(3, 1, add_more_to_count_simple);
602 map.update_with_key(9, 1, add_more_to_count);
603 map.update(3, 7, add_more_to_count_simple);
604 map.update_with_key(5, 3, add_more_to_count);
605 map.update_with_key(3, 2, add_more_to_count);
607 // check the total counts
608 assert_eq!(map.find(&3).unwrap(), &10);
609 assert_eq!(map.find(&5).unwrap(), &3);
610 assert_eq!(map.find(&9).unwrap(), &1);
612 // sadly, no sevens were counted
613 assert!(map.find(&7).is_none());
618 let mut m = SmallIntMap::new();
619 assert_eq!(m.swap(1, 2i), None);
620 assert_eq!(m.swap(1, 3i), Some(2));
621 assert_eq!(m.swap(1, 4i), Some(3));
626 let mut m = SmallIntMap::new();
628 assert_eq!(m.pop(&1), Some(2));
629 assert_eq!(m.pop(&1), None);
634 let mut map = SmallIntMap::new();
638 let keys = map.keys().collect::<Vec<uint>>();
639 assert_eq!(keys.len(), 3);
640 assert!(keys.contains(&1));
641 assert!(keys.contains(&2));
642 assert!(keys.contains(&3));
647 let mut map = SmallIntMap::new();
651 let values = map.values().map(|&v| v).collect::<Vec<char>>();
652 assert_eq!(values.len(), 3);
653 assert!(values.contains(&'a'));
654 assert!(values.contains(&'b'));
655 assert!(values.contains(&'c'));
660 let mut m = SmallIntMap::new();
662 assert!(m.insert(0, 1i));
663 assert!(m.insert(1, 2));
664 assert!(m.insert(3, 5));
665 assert!(m.insert(6, 10));
666 assert!(m.insert(10, 11));
668 let mut it = m.iter();
669 assert_eq!(it.size_hint(), (0, Some(11)));
670 assert_eq!(it.next().unwrap(), (0, &1));
671 assert_eq!(it.size_hint(), (0, Some(10)));
672 assert_eq!(it.next().unwrap(), (1, &2));
673 assert_eq!(it.size_hint(), (0, Some(9)));
674 assert_eq!(it.next().unwrap(), (3, &5));
675 assert_eq!(it.size_hint(), (0, Some(7)));
676 assert_eq!(it.next().unwrap(), (6, &10));
677 assert_eq!(it.size_hint(), (0, Some(4)));
678 assert_eq!(it.next().unwrap(), (10, &11));
679 assert_eq!(it.size_hint(), (0, Some(0)));
680 assert!(it.next().is_none());
684 fn test_iterator_size_hints() {
685 let mut m = SmallIntMap::new();
687 assert!(m.insert(0, 1i));
688 assert!(m.insert(1, 2));
689 assert!(m.insert(3, 5));
690 assert!(m.insert(6, 10));
691 assert!(m.insert(10, 11));
693 assert_eq!(m.iter().size_hint(), (0, Some(11)));
694 assert_eq!(m.iter().rev().size_hint(), (0, Some(11)));
695 assert_eq!(m.iter_mut().size_hint(), (0, Some(11)));
696 assert_eq!(m.iter_mut().rev().size_hint(), (0, Some(11)));
700 fn test_mut_iterator() {
701 let mut m = SmallIntMap::new();
703 assert!(m.insert(0, 1i));
704 assert!(m.insert(1, 2));
705 assert!(m.insert(3, 5));
706 assert!(m.insert(6, 10));
707 assert!(m.insert(10, 11));
709 for (k, v) in m.iter_mut() {
713 let mut it = m.iter();
714 assert_eq!(it.next().unwrap(), (0, &1));
715 assert_eq!(it.next().unwrap(), (1, &3));
716 assert_eq!(it.next().unwrap(), (3, &8));
717 assert_eq!(it.next().unwrap(), (6, &16));
718 assert_eq!(it.next().unwrap(), (10, &21));
719 assert!(it.next().is_none());
723 fn test_rev_iterator() {
724 let mut m = SmallIntMap::new();
726 assert!(m.insert(0, 1i));
727 assert!(m.insert(1, 2));
728 assert!(m.insert(3, 5));
729 assert!(m.insert(6, 10));
730 assert!(m.insert(10, 11));
732 let mut it = m.iter().rev();
733 assert_eq!(it.next().unwrap(), (10, &11));
734 assert_eq!(it.next().unwrap(), (6, &10));
735 assert_eq!(it.next().unwrap(), (3, &5));
736 assert_eq!(it.next().unwrap(), (1, &2));
737 assert_eq!(it.next().unwrap(), (0, &1));
738 assert!(it.next().is_none());
742 fn test_mut_rev_iterator() {
743 let mut m = SmallIntMap::new();
745 assert!(m.insert(0, 1i));
746 assert!(m.insert(1, 2));
747 assert!(m.insert(3, 5));
748 assert!(m.insert(6, 10));
749 assert!(m.insert(10, 11));
751 for (k, v) in m.iter_mut().rev() {
755 let mut it = m.iter();
756 assert_eq!(it.next().unwrap(), (0, &1));
757 assert_eq!(it.next().unwrap(), (1, &3));
758 assert_eq!(it.next().unwrap(), (3, &8));
759 assert_eq!(it.next().unwrap(), (6, &16));
760 assert_eq!(it.next().unwrap(), (10, &21));
761 assert!(it.next().is_none());
765 fn test_move_iter() {
766 let mut m = SmallIntMap::new();
768 let mut called = false;
769 for (k, v) in m.into_iter() {
773 assert_eq!(v, box 2i);
781 let mut map = SmallIntMap::new();
782 let empty = SmallIntMap::<int>::new();
787 let map_str = map.to_string();
788 let map_str = map_str.as_slice();
789 assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
790 assert_eq!(format!("{}", empty), "{}".to_string());
795 let mut a = SmallIntMap::new();
801 assert!(a.clone() == a);
806 let mut a = SmallIntMap::new();
807 let mut b = SmallIntMap::new();
810 assert!(a.insert(0, 5i));
812 assert!(b.insert(0, 4i));
814 assert!(a.insert(5, 19));
816 assert!(!b.insert(0, 5));
818 assert!(b.insert(5, 19));
824 let mut a = SmallIntMap::new();
825 let mut b = SmallIntMap::new();
827 assert!(!(a < b) && !(b < a));
828 assert!(b.insert(2u, 5i));
830 assert!(a.insert(2, 7));
831 assert!(!(a < b) && b < a);
832 assert!(b.insert(1, 0));
834 assert!(a.insert(0, 6));
836 assert!(a.insert(6, 2));
837 assert!(a < b && !(b < a));
842 let mut a = SmallIntMap::new();
843 let mut b = SmallIntMap::new();
845 assert!(a <= b && a >= b);
846 assert!(a.insert(1u, 1i));
847 assert!(a > b && a >= b);
848 assert!(b < a && b <= a);
849 assert!(b.insert(2, 2));
850 assert!(b > a && b >= a);
851 assert!(a < b && a <= b);
856 let mut x = SmallIntMap::new();
857 let mut y = SmallIntMap::new();
859 assert!(hash::hash(&x) == hash::hash(&y));
868 assert!(hash::hash(&x) == hash::hash(&y));
872 fn test_from_iter() {
873 let xs: Vec<(uint, char)> = vec![(1u, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')];
875 let map: SmallIntMap<char> = xs.iter().map(|&x| x).collect();
877 for &(k, v) in xs.iter() {
878 assert_eq!(map.find(&k), Some(&v));
884 let mut map: SmallIntMap<int> = SmallIntMap::new();
890 assert_eq!(map[3], 4);
895 fn test_index_nonexistent() {
896 let mut map: SmallIntMap<int> = SmallIntMap::new();
909 use self::test::Bencher;
910 use super::SmallIntMap;
911 use deque::bench::{insert_rand_n, insert_seq_n, find_rand_n, find_seq_n};
915 pub fn insert_rand_100(b: &mut Bencher) {
916 let mut m : SmallIntMap<uint> = SmallIntMap::new();
917 insert_rand_n(100, &mut m, b);
921 pub fn insert_rand_10_000(b: &mut Bencher) {
922 let mut m : SmallIntMap<uint> = SmallIntMap::new();
923 insert_rand_n(10_000, &mut m, b);
928 pub fn insert_seq_100(b: &mut Bencher) {
929 let mut m : SmallIntMap<uint> = SmallIntMap::new();
930 insert_seq_n(100, &mut m, b);
934 pub fn insert_seq_10_000(b: &mut Bencher) {
935 let mut m : SmallIntMap<uint> = SmallIntMap::new();
936 insert_seq_n(10_000, &mut m, b);
941 pub fn find_rand_100(b: &mut Bencher) {
942 let mut m : SmallIntMap<uint> = SmallIntMap::new();
943 find_rand_n(100, &mut m, b);
947 pub fn find_rand_10_000(b: &mut Bencher) {
948 let mut m : SmallIntMap<uint> = SmallIntMap::new();
949 find_rand_n(10_000, &mut m, b);
954 pub fn find_seq_100(b: &mut Bencher) {
955 let mut m : SmallIntMap<uint> = SmallIntMap::new();
956 find_seq_n(100, &mut m, b);
960 pub fn find_seq_10_000(b: &mut Bencher) {
961 let mut m : SmallIntMap<uint> = SmallIntMap::new();
962 find_seq_n(10_000, &mut m, b);