Trait mapgraph::map::KeySet

source ·
pub trait KeySet<K: Copy + Eq + Debug + 'static> {
    // Required methods
    fn len(&self) -> usize;
    fn contains(&self, index: K) -> bool;
    fn insert(&mut self, index: K) -> bool;
    fn remove(&mut self, index: K) -> bool;
    fn clear(&mut self);

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A set of keys.

This is used to mark keys that have already been visited in algorithms.

Implementing this using a separate trait instead of relying on the ExtKeyMap trait allows to use simpler set structures like bit sets with less friction.

Auto trait implementations

All types that implement [ExtKeyMap<()>] automatically implement this trait.

Required Methods§

source

fn len(&self) -> usize

Returns the amount of keys in the set.

source

fn contains(&self, index: K) -> bool

Returns true if a set contains the specified key.

source

fn insert(&mut self, index: K) -> bool

Inserts a key into the set.

Returns true if the value was not present in the set.

source

fn remove(&mut self, index: K) -> bool

Removes a key from the set.

Returns true if the value was present in the set.

source

fn clear(&mut self)

Removes all the nodes from the map.

Provided Methods§

source

fn is_empty(&self) -> bool

Returns true if the set is empty.

Implementations on Foreign Types§

source§

impl<K, S> KeySet<K> for HashSet<K, S>
where K: Copy + Eq + Hash + Debug + 'static, S: BuildHasher + Default,

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn contains(&self, index: K) -> bool

source§

fn insert(&mut self, index: K) -> bool

source§

fn remove(&mut self, index: K) -> bool

source§

fn clear(&mut self)

source§

impl<K: Copy + Eq + Ord + Debug + 'static> KeySet<K> for BTreeSet<K>

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn contains(&self, index: K) -> bool

source§

fn insert(&mut self, index: K) -> bool

source§

fn remove(&mut self, index: K) -> bool

source§

fn clear(&mut self)

Implementors§

source§

impl<K: Copy + Eq + Debug + 'static, T: ExtKeyMap<(), Key = K>> KeySet<K> for T