MCPcopy Create free account
hub / github.com/hashintel/hash / insert

Method insert

libs/@local/hashql/core/src/id/vec.rs:541–543  ·  view source on GitHub ↗

Inserts a value at the given ID index, expanding the vector if necessary. If the vector is shorter than the index, it will be extended with `None` values. This enables sparse, map-like usage patterns. # Examples ``` # use hashql_core::id::{IdVec, Id as _, newtype}; # newtype!(struct MyId(u32 is 0..=0xFFFF_FF00)); let mut vec = IdVec:: >::new(); vec.insert(MyId::from_usize(5)

(&mut self, index: I, value: T)

Source from the content-addressed store, hash-verified

539 /// assert_eq!(vec[MyId::from_usize(5)].as_ref().unwrap(), "hello");
540 /// ```
541 pub fn insert(&mut self, index: I, value: T) -> Option<T> {
542 self.fill_until(index, || None).replace(value)
543 }
544
545 /// Gets the value at `index`, or inserts one by calling `value` if it doesn't exist.
546 ///

Callers 15

dense_insertFunction · 0.45
dense_containsFunction · 0.45
dense_union_rowsFunction · 0.45
dense_transitive_closureFunction · 0.45
dense_row_iterFunction · 0.45
sparse_insertFunction · 0.45
sparse_union_rowsFunction · 0.45
sparse_clear_reuseFunction · 0.45
intern_partsMethod · 0.45
enqueueMethod · 0.45
push_start_nodeMethod · 0.45
nextMethod · 0.45

Calls 2

replaceMethod · 0.80
fill_untilMethod · 0.45

Tested by

no test coverage detected