pub struct LinkedHashSet<T, S = BuildHasherDefault<DefaultHasher>> { /* private fields */ }
Expand description

A HashSet that holds elements in insertion order.

Examples

use ckb_util::LinkedHashSet;

let mut set = LinkedHashSet::new();
set.insert(2);
set.insert(1);
set.insert(3);

let items: Vec<i32> = set.iter().copied().collect();
assert_eq!(items, [2, 1, 3]);

Implementations

Creates a linked hash set.

Examples
use ckb_util::LinkedHashSet;
let set: LinkedHashSet<i32> = LinkedHashSet::new();

Creates an empty linked hash map with the given initial capacity.

Examples
use ckb_util::LinkedHashSet;
let set: LinkedHashSet<i32> = LinkedHashSet::with_capacity(42);

Returns true if the set contains a value.

use ckb_util::LinkedHashSet;

let mut set: LinkedHashSet<_> = LinkedHashSet::new();
set.insert(1);
set.insert(2);
set.insert(3);
assert_eq!(set.contains(&1), true);
assert_eq!(set.contains(&4), false);

Returns the number of elements the set can hold without reallocating.

Returns the number of elements in the set.

Returns true if the set contains no elements.

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.

Gets an iterator visiting all elements in insertion order.

The iterator element type is &'a T.

Visits the values representing the difference, i.e., the values that are in self but not in other.

Trait Implementations

Creates an empty HashSet<T> with the Default value for the hasher.

Extends a collection with the contents of an iterator. Read more

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.