pub fn make_singleton(&mut self, index: usize) {
        let mut current = self.meta[index].link();

        if current != index {
            // We make this the new root.
            let root = current;
            self.meta[root].set_rank(1);

            // All parents except for the last are updated.
            while self.meta[current].link() != index {
                self.meta[current].set_parent(root);

                current = self.meta[current].link();
            }

            // We change the last parent and link.
            self.meta[current].set_parent(root);
            self.meta[current].set_link(root);
        }

        self.meta[index] = Metadata::new(index);
    }
/// Will remove `index` from its set while leaving the other members in it.
///
/// After this `index` will be the only element of its set.
/// This won't change the `PartitionVec<T>` if `index` is already the only element.
/// This method will be executed in `O(m)` time where `m` is the size of the set of `index`.
///
/// # Examples
///
/// ```
/// # #[macro_use]
/// # extern crate partitions;
/// #
/// # fn main() {
/// let mut partition_vec = partition_vec![
///     () => 'a',
///     () => 'a',
///     () => 'a',
///     () => 'b',
/// ];
///
/// // 0, 1, and 2 share a set.
/// assert!(partition_vec.len_of_set(0) == 3);
/// assert!(partition_vec.len_of_set(1) == 3);
/// assert!(partition_vec.len_of_set(2) == 3);
/// assert!(partition_vec.len_of_set(3) == 1);
///
/// partition_vec.make_singleton(2);
///
/// // Now 2 has its own set and 1, and 2 still share a set.
/// assert!(partition_vec.len_of_set(0) == 2);
/// assert!(partition_vec.len_of_set(1) == 2);
/// assert!(partition_vec.len_of_set(2) == 1);
/// assert!(partition_vec.len_of_set(3) == 1);
/// # }
/// ```
Will remove `index` from its set while leaving the other members in it.
After this `index` will be the only element of its set.
This won't change the `PartitionVec` if `index` is already the only element.
Will remove ` index ` from its set while leaving the other members in it . After this ` index ` will be the only element of its set . This won ' t change the ` PartitionVec ` if ` index ` is already the only element .
pub fn make_singleton(&mut self, index: usize) {
        let mut current = self.meta[index].link();
        if current != index {
            // We make this the new root.
            let root = current;
            self.meta[root].set_rank(1);
            // All parents except for the last are updated.
            while self.meta[current].link() != index {
                self.meta[current].set_parent(root);
                current = self.meta[current].link();
            }
            // We change the last parent and link.
            self.meta[current].set_parent(root);
            self.meta[current].set_link(root);
        }
        self.meta[index] = Metadata::new(index);
    }
pub fn make_singleton ( & mut self , index : usize ) { let mut current = self . meta [ index ] . link ( ) ; if current != index { // We make this the new root. let root = current ; self . meta [ root ] . set_rank ( 1 ) ; // All parents except for the last are updated. while self . meta [ current ] . link ( ) != index { self . meta [ current ] . set_parent ( root ) ; current = self . meta [ current ] . link ( ) ; } // We change the last parent and link. self . meta [ current ] . set_parent ( root ) ; self . meta [ current ] . set_link ( root ) ; } self . meta [ index ] = Metadata :: new ( index ) ; }
Will remove `index` from its set while leaving the other members in it.
Will remove ` index ` from its set while leaving the other members in it .
&mut self
index
usize
&mut self
index
usize
examples
None
#[macro_use]
None
extern crate partitions;
None
fn main() {


0, 1, and 2 share a set.

partition_vec.make_singleton(2).

Now 2 has its own set and 1, and 2 still share a set.
0 1 and 2 share a set . partition_vec . make_singleton ( 2 ) . Now 2 has its own set and 1 and 2 still share a set .
}
None