Struct content_tree::ContentTreeRaw[][src]

pub struct ContentTreeRaw<E: ContentTraits, I: TreeIndex<E>, const INT_ENTRIES: usize, const LEAF_ENTRIES: usize> { /* fields omitted */ }
Expand description

A ContentTree is an efficient packed list of RLE entries, allowing for arbitrary inserts and deletes anywhere in the range.

use content_tree::ContentTree;
use content_tree::testrange::TestRange;

let mut tree = ContentTree::new();
tree.push(TestRange { id: 0, len: 100, is_activated: true });
tree.push(TestRange { id: 100, len: 50, is_activated: true });

assert_eq!(tree.raw_iter().collect::<Vec<TestRange>>(), vec![
    TestRange { id: 0, len: 150, is_activated: true }
]);

Implementations

Iterate through all the items “raw” - which is to say, without merging anything.

This is different from iter() because in some editing situations the tree will not be perfectly flattened. That is, it may be possible to merge some items in the tree. This iterator method will not merge anything, and instead just iterate through all items as they are stored.

Whether specific items are merged or not is an implementation detail, and should not be relied upon by your application. If you expect all mergable items to be merged, use iter().

Iterate through all entries in the content tree. This iterator will yield all entries merged according to the methods in SplitableSpan.

pub fn next_entry_or_panic(
    cursor: &mut UnsafeCursor<E, I, IE, LE>,
    marker: &mut I::IndexUpdate
)

Returns a cursor right before the named location, referenced by the pointer.

This file contains the core code for content-tree’s mutation operations.

Push a new entry to the end of the tree. The new entry will be merged with the existing last entry if possible.

pub unsafe fn unsafe_mutate_entry_notify<MapFn, N>(
    map_fn: MapFn,
    cursor: &mut UnsafeCursor<E, I, IE, LE>,
    replace_max: usize,
    flush_marker: &mut I::IndexUpdate,
    notify: &mut N
) -> usize where
    N: FnMut(E, NonNull<NodeLeaf<E, I, IE, LE>>),
    MapFn: FnOnce(&mut E), 

Replace as much of the current entry from cursor onwards as we can

Replace the range from cursor..cursor + replaced_len with new_entry.

Delete the specified number of items from the b-tree at the cursor. Cursor may be modified to point to the start of the next item.

Deactivate up to max_deleted_len from the marker tree, at the location specified by cursor. We will always process at least one item. Consumers of this API should call this in a loop.

If the entry is already marked as deleted, unlike local_deactivate, this method does nothing. local_deactivate will skip over deleted items and delete something else.

Returns the number of items we tried to deactivate, and whether we were successful. (eg (1, true) means we marked 1 item for deletion. (2, false) means we skipped past 2 items which were already deactivated.

TODO: It might be cleaner to make the caller check for deleted items if we return 0.

TODO: Consider returning / mutating the cursor. Subsequent items will probably be in this node. It would be marginally faster to find a cursor using a hint, and subsequent deletes in the txn we’re applying will usually be in this node (usually the next item in this node).

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.