Skip to content

Commit

Permalink
Implement FlurryHashSet iter()
Browse files Browse the repository at this point in the history
  • Loading branch information
twe4ked committed Feb 2, 2020
1 parent 1182d0c commit e83474e
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/set/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
use std::hash::Hash;

use crate::epoch;
use crate::epoch::{self, Guard};
use crate::iter::Keys;
use crate::HashMap;

/// A concurrent hash set.
Expand Down Expand Up @@ -98,4 +99,26 @@ where
let removed = self.map.remove(value, &guard);
removed.is_some()
}

/// An iterator over the set's values.
///
/// See [`FlurryHashMap::keys`] for details.
///
/// # Examples
///
/// ```
/// use flurry::FlurryHashSet;
///
/// let set = FlurryHashSet::new();
/// set.insert(1);
/// set.insert(2);
///
/// let guard = flurry::epoch::pin();
/// for x in set.iter(&guard) {
/// println!("{}", x);
/// }
/// ```
pub fn iter<'g>(&'g self, guard: &'g Guard) -> Keys<'g, T, ()> {
self.map.keys(guard)
}
}

0 comments on commit e83474e

Please sign in to comment.