MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / insert

Method insert

atomic-core/src/crdt/apply/order.rs:360–368  ·  view source on GitHub ↗

Inserts an element at its correct position. # Arguments `id` - The ID of the element to insert `after` - The ID this element should be inserted after, or `None` for start # Returns The index at which the element was inserted.

(&mut self, id: Id, after: Option<Id>)

Source from the content-addressed store, hash-verified

358 ///
359 /// The index at which the element was inserted.
360 pub fn insert(&mut self, id: Id, after: Option<Id>) -> usize {
361 let position = self.resolve_position(&id, &after);
362 let index = position.to_insert_index(self.elements.len());
363
364 self.elements.insert(index, id);
365 self.after_refs.insert(index, after);
366
367 index
368 }
369
370 /// Resolves the insertion position for a new element.
371 ///

Callers 15

test_branch_id_hashFunction · 0.45
put_trunkMethod · 0.45
update_trunk_pathMethod · 0.45
put_branchMethod · 0.45
put_leafMethod · 0.45
test_sequence_branch_idsFunction · 0.45
test_sequence_get_afterFunction · 0.45
test_sequence_iterFunction · 0.45

Calls 3

resolve_positionMethod · 0.80
to_insert_indexMethod · 0.80
lenMethod · 0.45

Tested by 15

test_branch_id_hashFunction · 0.36
test_sequence_branch_idsFunction · 0.36
test_sequence_get_afterFunction · 0.36
test_sequence_iterFunction · 0.36
test_sequence_containsFunction · 0.36
test_sequence_positionFunction · 0.36
test_sequence_removeFunction · 0.36