pub fn insert_weight(&mut self, node: T, vnodes: usize) {
        let node_hash = self.hash(&node);

        let mut hash = node_hash;
        // insert new vnodes
        for _ in 0..vnodes.saturating_sub(1) {
            self.vnodes.map_insert(hash, (node.clone(), node_hash));
            hash = self.hash(hash);
        }
        if vnodes > 0 {
            self.vnodes.map_insert(hash, (node, node_hash));
            hash = self.hash(hash);
        }

        // remove old vnodes (if any are present)
        while self.vnodes.map_remove(&hash).is_some() {
            hash = self.hash(hash);
        }

        self.unique.map_insert(node_hash, vnodes);
    }
/// Insert a node into the ring with the provided number of vnodes.
///
/// This can be used give some nodes more weight than others - nodes with
/// more vnodes will be selected for larger proportions of keys.
///
/// If the provided node is already present in the ring, the count is updated.
///
/// O(k * v + (v * log k) + log k + n + log n)
///
/// ```
/// use consistent_hash_ring::*;
///
/// let mut ring = Ring::default();
/// ring.insert(b"hello worldo");
/// ring.insert_weight(b"worldo hello", 9);
/// assert_eq!(2, ring.len());
/// assert_eq!(Some(10), ring.weight(&b"hello worldo"));
/// assert_eq!(Some(9), ring.weight(&b"worldo hello"));
/// ```
Insert a node into the ring with the provided number of vnodes.
This can be used give some nodes more weight than others - nodes with
more vnodes will be selected for larger proportions of keys.

If the provided node is already present in the ring, the count is updated.






Insert a node into the ring with the provided number of vnodes . This can be used give some nodes more weight than others - nodes with more vnodes will be selected for larger proportions of keys . If the provided node is already present in the ring the count is updated .
pub fn insert_weight(&mut self, node: T, vnodes: usize) {
        let node_hash = self.hash(&node);
        let mut hash = node_hash;
        // insert new vnodes
        for _ in 0..vnodes.saturating_sub(1) {
            self.vnodes.map_insert(hash, (node.clone(), node_hash));
            hash = self.hash(hash);
        }
        if vnodes > 0 {
            self.vnodes.map_insert(hash, (node, node_hash));
            hash = self.hash(hash);
        }
        // remove old vnodes (if any are present)
        while self.vnodes.map_remove(&hash).is_some() {
            hash = self.hash(hash);
        }
        self.unique.map_insert(node_hash, vnodes);
    }
pub fn insert_weight ( & mut self , node : T , vnodes : usize ) { let node_hash = self . hash ( & node ) ; let mut hash = node_hash ; // insert new vnodes for _ in 0 .. vnodes . saturating_sub ( 1 ) { self . vnodes . map_insert ( hash , ( node . clone ( ) , node_hash ) ) ; hash = self . hash ( hash ) ; } if vnodes > 0 { self . vnodes . map_insert ( hash , ( node , node_hash ) ) ; hash = self . hash ( hash ) ; } // remove old vnodes (if any are present) while self . vnodes . map_remove ( & hash ) . is_some ( ) { hash = self . hash ( hash ) ; } self . unique . map_insert ( node_hash , vnodes ) ; }
Insert a node into the ring with the provided number of vnodes.
Insert a node into the ring with the provided number of vnodes .
&mut self
node
T
vnodes
usize
&mut self
node
T
vnodes
usize