pub struct RBTree<A: Adapter<Link = Link>> { /* private fields */ }
Expand description

An intrusive red-black tree.

When this collection is dropped, all elements linked into it will be converted back to owned pointers and dropped.

Note that you are responsible for ensuring that the elements in a RBTree remain in ascending key order. This property can be violated, either because the key of an element was modified, or because the insert_before/insert_after methods of CursorMut were incorrectly used. If this situation occurs, memory safety will not be violated but the find, upper_bound, lower_bound and range may return incorrect results.

Implementations

Creates an empty RBTree.

Returns true if the RBTree is empty.

Returns a null Cursor for this tree.

Returns a null CursorMut for this tree.

Creates a Cursor from a pointer to an element.

Safety

ptr must be a pointer to an object that is part of this tree.

Creates a CursorMut from a pointer to an element.

Safety

ptr must be a pointer to an object that is part of this tree.

Returns a Cursor pointing to the first element of the tree. If the tree is empty then a null cursor is returned.

Returns a CursorMut pointing to the first element of the tree. If the the tree is empty then a null cursor is returned.

Returns a Cursor pointing to the last element of the tree. If the tree is empty then a null cursor is returned.

Returns a CursorMut pointing to the last element of the tree. If the tree is empty then a null cursor is returned.

Gets an iterator over the objects in the RBTree, in ascending key order.

Removes all elements from the RBTree.

This will unlink all object currently in the tree, which requires iterating through all elements in the RBTree. Each element is converted back to an owned pointer and then dropped.

Empties the RBTree without unlinking or freeing objects in it.

Since this does not unlink any objects, any attempts to link these objects into another RBTree will fail but will not cause any memory unsafety. To unlink those objects manually, you must call the force_unlink function on them.

Takes all the elements out of the RBTree, leaving it empty. The taken elements are returned as a new RBTree.

Returns a Cursor pointing to an element with the given key. If no such element is found then a null cursor is returned.

If multiple elements with an identical key are found then an arbitrary one is returned.

Returns a CursorMut pointing to an element with the given key. If no such element is found then a null cursor is returned.

If multiple elements with an identical key are found then an arbitrary one is returned.

Returns a Cursor pointing to the lowest element whose key is above the given bound. If no such element is found then a null cursor is returned.

Returns a CursorMut pointing to the first element whose key is above the given bound. If no such element is found then a null cursor is returned.

Returns a Cursor pointing to the last element whose key is below the given bound. If no such element is found then a null cursor is returned.

Returns a CursorMut pointing to the last element whose key is below the given bound. If no such element is found then a null cursor is returned.

Inserts a new element into the RBTree.

The new element will be inserted at the correct position in the tree based on its key.

Returns a mutable cursor pointing to the newly added element.

Panics

Panics if the new element is already linked to a different intrusive collection.

Returns an Entry for the given key which contains a CursorMut to an element with the given key or an InsertCursor which points to a place in which to insert a new element with the given key.

This is more efficient than calling find followed by insert since the tree does not have to be searched a second time to find a place to insert the new element.

If multiple elements with an identical key are found then an arbitrary one is returned.

Constructs a double-ended iterator over a sub-range of elements in the tree, starting at min, and ending at max. If min is Unbounded, then it will be treated as “negative infinity”, and if max is Unbounded, then it will be treated as “positive infinity”. Thus range(Unbounded, Unbounded) will yield the whole collection.

Trait Implementations

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Executes the destructor for this type. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.