pub fn insert(&mut self, elem: &'a T) -> Result<()> {
		let set = &mut self.set;

		if let Entry::Vacant(entry) = self.map.entry(elem) {
			entry.insert(set.len());
			Ok(())
		} else {
			Err(HashDisjointSetError::DuplicateElement)
		}?;

		set.push(Unit {
			size: 1,
			parent: set.len(),
		});
		self.subset_count += 1;
		self.ver += 1;

		Ok(())
	}
/// Adds an element to the `HashDisjointSet`.
/// The added element is considered part of a new disjoint subset
/// containing only that element.
///
/// # Examples
///
/// ```
/// # use union_find::hash_disjoint_set::HashDisjointSet;
/// # use std::iter::FromIterator;
/// # use union_find::UnionFind;
/// #
/// let mut set = HashDisjointSet::from_iter(b"This is a test.");
/// let result = set.insert(&b'Q').unwrap();
///
/// assert_eq!(result, ());
/// assert_eq!(10, set.subset_count());
/// ```
///
/// # Failures
/// An error is returned if the provided element is not in the set.
/// ```
/// # use union_find::hash_disjoint_set::{HashDisjointSet, HashDisjointSetError};
/// # use std::iter::FromIterator;
/// # use union_find::UnionFind;
/// #
/// let mut set = HashDisjointSet::from_iter(b"This is a test.");
/// let result = set.insert(&b'T').unwrap_err();
///
/// assert_eq!(result, HashDisjointSetError::DuplicateElement);
/// ```
Adds an element to the `HashDisjointSet`.
The added element is considered part of a new disjoint subset
containing only that element.
Adds an element to the ` HashDisjointSet ` . The added element is considered part of a new disjoint subset containing only that element .
pub fn insert(&mut self, elem: &'a T) -> Result<()> {
		let set = &mut self.set;
		if let Entry::Vacant(entry) = self.map.entry(elem) {
			entry.insert(set.len());
			Ok(())
		} else {
			Err(HashDisjointSetError::DuplicateElement)
		}?;
		set.push(Unit {
			size: 1,
			parent: set.len(),
		});
		self.subset_count += 1;
		self.ver += 1;
		Ok(())
	}
pub fn insert ( & mut self , elem : & ' a T ) -> Result < ( ) > { let set = & mut self . set ; if let Entry :: Vacant ( entry ) = self . map . entry ( elem ) { entry . insert ( set . len ( ) ) ; Ok ( ( ) ) } else { Err ( HashDisjointSetError :: DuplicateElement ) } ? ; set . push ( Unit { size : 1 , parent : set . len ( ) , } ) ; self . subset_count += 1 ; self . ver += 1 ; Ok ( ( ) ) }
Adds an element to the `HashDisjointSet`.
Adds an element to the ` HashDisjointSet ` .
&mut self
elem
&'a T
examples
None
use union_find::hash_disjoint_set::hashdisjointset;
None
use std::iter::fromiterator;
None
use union_find::unionfind;
let mut set = HashDisjointSet::from_iter(b"This is a test.");
let result = set.insert(&b'Q').unwrap().


let mut set = HashDisjointSet :: from_iter ( b " This is a test . " ) ; let result = set . insert ( &b ' Q ' ) . unwrap () .
failures
An error is returned if the provided element is not in the set.
An error is returned if the provided element is not in the set .
use union_find::hash_disjoint_set::{hashdisjointset, hashdisjointseterror};
None
use std::iter::fromiterator;
None
use union_find::unionfind;
let mut set = HashDisjointSet::from_iter(b"This is a test.");
let result = set.insert(&b'T').unwrap_err().

assert_eq!(result, HashDisjointSetError::DuplicateElement);
```
let mut set = HashDisjointSet :: from_iter ( b " This is a test . " ) ; let result = set . insert ( &b ' T ' ) . unwrap_err () . assert_eq! ( result HashDisjointSetError :: DuplicateElement ) ; ` ` `