Struct IndexMultiMap

Source
pub struct IndexMultiMap<K, V, Node = Vec<MultiPair<K, V>>>
where K: Send + Ord + Clone + 'static, V: Send + Clone + PartialEq + 'static, Node: NodeLike<MultiPair<K, V>> + Send + 'static,
{ /* private fields */ }

Implementations§

Source§

impl<K, V, Node> BTreeMultiMap<K, V, Node>
where K: Send + Ord + Clone + 'static, V: Send + Clone + PartialEq + 'static, Node: NodeLike<MultiPair<K, V>> + Send + 'static,

Source

pub fn new() -> BTreeMultiMap<K, V, Node>

Makes a new, empty, persistent BTreeMultiMap.

§Examples

Basic usage:

use indexset::concurrent::multimap::BTreeMultiMap;

let mut map = BTreeMultiMap::<usize, &str>::new();

// entries can now be inserted into the empty map
map.insert(1, "a");
Source

pub fn with_maximum_node_size(node_capacity: usize) -> BTreeMultiMap<K, V, Node>

Makes a new, empty BTreeMultiMap with the given maximum node size. Allocates one vec with the capacity set to be the specified node size.

§Examples
use indexset::concurrent::multimap::BTreeMultiMap;

let map = BTreeMultiMap::<i32, i32>::with_maximum_node_size(128);
Source

pub fn attach_multi_node(&self, node: Node)

Adds full [Node] to this multiset. [Node] should be correct node with values sorted.

Source

pub fn iter_nodes(&self) -> impl Iterator<Item = Arc<Mutex<RawMutex, Node>>>

Returns iterator over this multiset’s [Node]’s.

Source

pub fn contains_key<Q>(&self, key: &Q) -> bool
where MultiPair<K, V>: Borrow<Q> + Ord, Q: Ord + ?Sized,

Returns true if the map contains at least one occurance of the specified key.

The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.

§Examples

Basic usage:

use indexset::concurrent::multimap::BTreeMultiMap;

let mut map = BTreeMultiMap::<usize, &str>::new();
map.insert(1, "a");
map.insert(1, "b");
assert_eq!(map.contains_key(&1), true);
assert_eq!(map.contains_key(&2), false);
Source

pub fn get(&self, key: &K) -> Range<'_, K, V, Node>

Constructs a double-ended iterator over all key value pairs with the given key in the map.

use indexset::concurrent::multimap::BTreeMultiMap;
use indexset::BTreeSet;

let mut map = BTreeMultiMap::<usize, &str>::new();
 
map.insert(1, "b");
map.insert(1, "a");
map.insert(2, "c");
 
let all_with_key = map.get(&1).collect::<BTreeSet<_>>();
assert_eq!(all_with_key.len(), 2);
assert_eq!(all_with_key, vec![(&1, &"a"), (&1, &"b")].into_iter().collect::<BTreeSet<_>>());
Source

pub fn insert(&self, key: K, value: V) -> Option<V>

Inserts a key-value pair into the multi map.

§Examples

Basic usage:

use indexset::concurrent::multimap::BTreeMultiMap;

let mut map = BTreeMultiMap::<usize, &str>::new();
assert_eq!(map.insert(37, "a"), None);
assert_eq!(map.len() == 0, false);

map.insert(37, "b");
assert_eq!(map.insert(37, "c"), None);
Source

pub fn insert_cdc( &self, key: K, value: V, ) -> (Option<V>, Vec<ChangeEvent<MultiPair<K, V>>>)

Inserts a key-value pair into the map and returns old value (if it was already in set) with ChangeEvent’s that describes this insert action.

Source

pub fn remove_some<Q>(&self, key: &Q) -> Option<(K, V)>
where MultiPair<K, V>: Borrow<Q> + Ord, Q: Ord + ?Sized,

Removes some key from the map that matches the given key, returning the key and the value if the key was previously in the map.

The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.

§Examples

Basic usage:

use indexset::concurrent::multimap::BTreeMultiMap;

let map = BTreeMultiMap::<usize, &str>::new();
map.insert(1, "b");
map.insert(1, "a");
 
let first_removed = map.remove_some(&1).unwrap();
let second_removed = map.remove_some(&1).unwrap();
let removals = vec![first_removed, second_removed];
 
assert!(removals.contains(&(1, "a")));
assert!(removals.contains(&(1, "b")));
Source

pub fn remove_some_cdc<Q>( &self, key: &Q, ) -> (Option<(K, V)>, Vec<ChangeEvent<MultiPair<K, V>>>)
where MultiPair<K, V>: Borrow<Q> + Ord, Q: Ord + ?Sized,

Removes some key from the map that matches the given key, returning the key and the value if the key was previously in the map with ChangeEvent’s describing this remove_some action.

Source

pub fn remove(&self, key: &K, value: &V) -> Option<(K, V)>

Removes a specific key-value pair from the map returning the key and the value if the key was previously in the map.

§Examples

Basic usage:

use indexset::concurrent::multimap::BTreeMultiMap;

let map = BTreeMultiMap::<usize, &str>::new();
map.insert(1, "b");
map.insert(1, "a");
 
assert_eq!(map.remove(&1, &"a"), Some((1, "a")));
assert_eq!(map.remove(&1, &"b"), Some((1, "b")));
Source

pub fn remove_cdc( &self, key: &K, value: &V, ) -> (Option<(K, V)>, Vec<ChangeEvent<MultiPair<K, V>>>)

Removes a specific key-value pair from the map returning the key and the value if the key was previously in the map with ChangeEvent’s describing this remove_some action.

Source

pub fn len(&self) -> usize

Returns the number of elements in the map.

§Examples

Basic usage:

use indexset::concurrent::multimap::BTreeMultiMap;

let mut a = BTreeMultiMap::<usize, &str>::new();
assert_eq!(a.len(), 0);
a.insert(1, "a");
assert_eq!(a.len(), 1);
Source

pub fn capacity(&self) -> usize

Returns the total number of allocated slots across all internal nodes.

This represents the number of key-value pairs the multimap can hold without reallocating memory in its internal vectors.

§Examples

Basic usage:

use indexset::concurrent::multimap::BTreeMultiMap;

let mut a = BTreeMultiMap::<usize, &str>::with_maximum_node_size(8);

a.insert(1, "a");
a.insert(1, "b");

// Capacity remains unchanged until reallocation occurs
assert_eq!(a.capacity(), 8);
Source

pub fn node_count(&self) -> usize

Returns the total number of nodes.

§Examples

Basic usage:

use indexset::concurrent::map::BTreeMap;

let mut a = BTreeMap::<usize, &str>::with_maximum_node_size(16);

a.insert(1, "a");
a.insert(2, "b");

assert_eq!(a.node_count(), 1);
Source

pub fn iter(&self) -> Iter<'_, K, V, Node>

Gets an iterator over the entries of the map, sorted by key.

§Examples

Basic usage:

use indexset::concurrent::multimap::BTreeMultiMap;

let mut map = BTreeMultiMap::<usize, &str>::new();
map.insert(3, "c");
map.insert(2, "b");
map.insert(1, "a");

for (key, value) in map.iter() {
    println!("{key}: {value}");
}

let (first_key, first_value) = map.iter().next().unwrap();
assert_eq!((*first_key, *first_value), (1, "a"));
Source

pub fn range<R>(&self, range: R) -> Range<'_, K, V, Node>
where R: RangeBounds<K>,

Constructs a double-ended iterator over a sub-range of elements in the map. The simplest way is to use the range syntax min..max, thus range(min..max) will yield elements from min (inclusive) to max (exclusive). The range may also be entered as (Bound<T>, Bound<T>), so for example range((Excluded(4), Included(10))) will yield a left-exclusive, right-inclusive range from 4 to 10.

§Panics

Panics if range start > end. Panics if range start == end and both bounds are Excluded.

§Examples

Basic usage:

use indexset::concurrent::multimap::BTreeMultiMap;
use std::ops::Bound::Included;

let mut map = BTreeMultiMap::<usize, &str>::new();
map.insert(3, "a");
map.insert(5, "b");
map.insert(8, "c");
for (&key, &value) in map.range((Included(&4), Included(&8))) {
    println!("{key}: {value}");
}
assert_eq!(Some((&5, &"b")), map.range(4..).next());

Trait Implementations§

Source§

impl<K, V, Node> Debug for BTreeMultiMap<K, V, Node>
where K: Debug + Send + Ord + Clone + 'static, V: Debug + Send + Clone + PartialEq + 'static, Node: Debug + NodeLike<MultiPair<K, V>> + Send + 'static,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<K, V, Node> Default for BTreeMultiMap<K, V, Node>
where K: Send + Ord + Clone + 'static, V: Send + Clone + PartialEq + 'static, Node: NodeLike<MultiPair<K, V>> + Send + 'static,

Source§

fn default() -> BTreeMultiMap<K, V, Node>

Returns the “default value” for a type. Read more
Source§

impl<T, Node> TableIndex<T> for IndexMultiMap<T, Link, Node>
where T: Eq + Hash + Clone + Send + Ord, Node: NodeLike<MultiPair<T, Link>> + Send + 'static,

Source§

fn insert(&self, value: T, link: Link) -> Option<Link>

Source§

fn remove(&self, value: T, link: Link) -> Option<(T, Link)>

Source§

impl<T, Node> TableIndexCdc<T> for IndexMultiMap<T, Link, Node>
where T: Eq + Hash + Clone + Send + Ord, Node: NodeLike<MultiPair<T, Link>> + Send + 'static,

Source§

fn insert_cdc( &self, value: T, link: Link, ) -> (Option<Link>, Vec<ChangeEvent<Pair<T, Link>>>)

Source§

fn remove_cdc( &self, value: T, link: Link, ) -> (Option<(T, Link)>, Vec<ChangeEvent<Pair<T, Link>>>)

Auto Trait Implementations§

§

impl<K, V, Node = Vec<MultiPair<K, V>>> !Freeze for BTreeMultiMap<K, V, Node>

§

impl<K, V, Node = Vec<MultiPair<K, V>>> !RefUnwindSafe for BTreeMultiMap<K, V, Node>

§

impl<K, V, Node> Send for BTreeMultiMap<K, V, Node>
where K: Sync, V: Sync,

§

impl<K, V, Node> Sync for BTreeMultiMap<K, V, Node>
where K: Sync, V: Sync,

§

impl<K, V, Node> Unpin for BTreeMultiMap<K, V, Node>

§

impl<K, V, Node = Vec<MultiPair<K, V>>> !UnwindSafe for BTreeMultiMap<K, V, Node>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more