Skip to main content

ACMapInsert

Trait ACMapInsert 

Source
pub trait ACMapInsert<S, V, H, W>{
    // Required methods
    fn map_insert_vec<F>(&mut self, dest: &mut Vec<(W, V)>, f: F)
       where F: Fn(&W, &mut V) -> Option<(W, V)> + Sync + Send;
    fn map_insert_multiple<F>(&mut self, dest: &mut Self, f: F)
       where F: Fn(&W, &mut V) -> Option<Vec<(W, V)>> + Sync + Send;
}
Expand description

In-place modify + insert pattern used to express branching gates (where one input entry can produce zero, one, or several output entries).

Required Methods§

Source

fn map_insert_vec<F>(&mut self, dest: &mut Vec<(W, V)>, f: F)
where F: Fn(&W, &mut V) -> Option<(W, V)> + Sync + Send,

Modify each existing entry in place; if f returns Some((k', v')), append that new entry into dest, a plain Vec (a push per entry, no hashing). This is the primary hot-path entry point: the caller merges the buffer into the destination map afterwards, avoiding a second hashmap probe per produced entry.

Source

fn map_insert_multiple<F>(&mut self, dest: &mut Self, f: F)
where F: Fn(&W, &mut V) -> Option<Vec<(W, V)>> + Sync + Send,

Like map_insert_vec but f may return a Vec of new entries per existing entry, inserted directly into the destination map dest.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a, S, C, Hasher, W> ACMapInsert<S, C, Hasher, W> for AHashMap<W, C, Hasher>
where S: PauliStorage + 'a, C: Coefficient + 'a, Hasher: Default + Clone + BuildHasher + 'a, W: PauliWordTrait + 'a,

Source§

fn map_insert_vec<F>(&mut self, dest: &mut Vec<(W, C)>, f: F)
where F: Fn(&W, &mut C) -> Option<(W, C)> + Sync + Send,

Source§

fn map_insert_multiple<F>(&mut self, dest: &mut AHashMap<W, C, Hasher>, f: F)
where F: Fn(&W, &mut C) -> Option<Vec<(W, C)>> + Sync + Send,

Source§

impl<'a, S, C, Hasher, W> ACMapInsert<S, C, Hasher, W> for HashMap<W, C, Hasher>
where S: PauliStorage + 'a, C: Coefficient + 'a, Hasher: Default + Clone + BuildHasher + 'a, W: PauliWordTrait + 'a,

Source§

fn map_insert_vec<F>(&mut self, dest: &mut Vec<(W, C)>, f: F)
where F: Fn(&W, &mut C) -> Option<(W, C)> + Sync + Send,

Source§

fn map_insert_multiple<F>(&mut self, dest: &mut HashMap<W, C, Hasher>, f: F)
where F: Fn(&W, &mut C) -> Option<Vec<(W, C)>> + Sync + Send,

Source§

impl<'a, S, C, Hasher, W> ACMapInsert<S, C, Hasher, W> for IndexMap<W, C, Hasher>
where S: PauliStorage + 'a, C: Coefficient + 'a, Hasher: Default + Clone + BuildHasher + 'a, W: PauliWordTrait + 'a,

Source§

fn map_insert_vec<F>(&mut self, dest: &mut Vec<(W, C)>, f: F)
where F: Fn(&W, &mut C) -> Option<(W, C)> + Sync + Send,

Source§

fn map_insert_multiple<F>(&mut self, dest: &mut IndexMap<W, C, Hasher>, f: F)
where F: Fn(&W, &mut C) -> Option<Vec<(W, C)>> + Sync + Send,

Source§

impl<S, C, H, W> ACMapInsert<S, C, H, W> for DashMap<W, C, H>

Source§

fn map_insert_vec<F>(&mut self, dest: &mut Vec<(W, C)>, f: F)
where F: Fn(&W, &mut C) -> Option<(W, C)> + Sync + Send,

Source§

fn map_insert_multiple<F>(&mut self, dest: &mut DashMap<W, C, H>, f: F)
where F: Fn(&W, &mut C) -> Option<Vec<(W, C)>> + Sync + Send,

Implementors§