Struct tinyset::u64set::Set64
[−]
[src]
pub struct Set64<T: Fits64>(_, _);
A set type that can store any type that fits in a u64
. This set
type is very space-efficient in storing small integers, while not
being bad at storing large integers (i.e. about half the size of a
large fnv::HashSet
, for small sets of large integers about five
times smaller than fnv::HashSet
.
Methods
impl<T: Fits64> Set64<T>
[src]
fn default() -> Self
Creates an empty set..
fn new() -> Self
Creates an empty set..
fn with_capacity(cap: usize) -> Self
Creates an empty set with the specified capacity.
fn with_max_and_capacity(max: T, cap: usize) -> Self
Creates an empty set with the specified capacity.
fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be
inserted in the set. The collection may reserve more space
to avoid frequent reallocations.
fn reserve_with_max(&mut self, max: T, additional: usize)
Reserves capacity for at least additional
more elements to
be inserted in the set, with maximum value of max
. The
collection may reserve more space to avoid frequent
reallocations.
fn insert(&mut self, elem: T) -> bool
Adds a value to the set.
If the set did not have this value present, true
is returned.
If the set did have this value present, false
is returned.
fn len(&self) -> usize
Returns the number of elements in the set.
fn contains<R: Borrow<T>>(&self, value: R) -> bool
Returns true if the set contains a value.
fn remove(&mut self, value: &T) -> bool
Removes an element, and returns true if that element was present.
fn iter(&self) -> Iter64<T>
Iterate
fn drain(&mut self) -> Drain64<T>
Drain
Trait Implementations
impl<T: Debug + Fits64> Debug for Set64<T>
[src]
impl<T: Clone + Fits64> Clone for Set64<T>
[src]
fn clone(&self) -> Set64<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: Fits64> FromIterator<T> for Set64<T>
[src]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
impl<'a, T: Fits64> IntoIterator for &'a Set64<T>
[src]
type Item = T
The type of the elements being iterated over.
type IntoIter = Iter64<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter64<'a, T>
Creates an iterator from a value. Read more
impl<'a, 'b, T: Fits64> Sub<&'b Set64<T>> for &'a Set64<T>
[src]
type Output = Set64<T>
The resulting type after applying the -
operator
fn sub(self, rhs: &Set64<T>) -> Set64<T>
Returns the difference of self
and rhs
as a new Set64<T>
.
Examples
use tinyset::Set64; let a: Set64<u32> = vec![1, 2, 3].into_iter().collect(); let b: Set64<u32> = vec![3, 4, 5].into_iter().collect(); let set = &a - &b; let mut i = 0; let expected = [1, 2]; for x in &set { assert!(expected.contains(&x)); i += 1; } assert_eq!(i, expected.len());
impl<T: Fits64> Extend<T> for Set64<T>
[src]
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Adds a bunch of elements to the set
Examples
use tinyset::Set64; let mut a: Set64<u32> = vec![1, 2, 3].into_iter().collect(); a.extend(vec![3, 4, 5]); let mut i = 0; let expected = [1, 2, 3, 4, 5]; for x in &a { assert!(expected.contains(&x)); i += 1; } assert_eq!(i, expected.len());
impl<'a, 'b, T: Fits64> BitOr<&'b Set64<T>> for &'a Set64<T>
[src]
type Output = Set64<T>
The resulting type after applying the |
operator
fn bitor(self, rhs: &Set64<T>) -> Set64<T>
Returns the union of self
and rhs
as a new Set64<T>
.
Examples
use tinyset::Set64; let a: Set64<u32> = vec![1, 2, 3].into_iter().collect(); let b: Set64<u32> = vec![3, 4, 5].into_iter().collect(); let set = &a | &b; let mut i = 0; let expected = [1, 2, 3, 4, 5]; for x in &set { assert!(expected.contains(&x)); i += 1; } assert_eq!(i, expected.len());