IndexSet in indexmap::set - Rust (original) (raw)

pub struct IndexSet<T, S = RandomState> { /* private fields */ }

Available on crate feature std only.

Expand description

A hash set where the iteration order of the values is independent of their hash values.

The interface is closely compatible with the standardHashSet, but also has additional features.

§Order

The values have a consistent order that is determined by the sequence of insertion and removal calls on the set. The order does not depend on the values or the hash function at all. Note that insertion order and value are not affected if a re-insertion is attempted once an element is already present.

All iterators traverse the set in order. Set operation iterators likeIndexSet::union produce a concatenated order, as do their matching “bitwise” operators. See their documentation for specifics.

The insertion order is preserved, with notable exceptions like the.remove() or .swap_remove() methods. Methods such as .sort_by() of course result in a new order, depending on the sorting order.

§Indices

The values are indexed in a compact range without holes in the range0..self.len(). For example, the method .get_full looks up the index for a value, and the method .get_index looks up the value by index.

§Complexity

Internally, IndexSet<T, S> just holds an IndexMap<T, (), S>. Thus the complexity of the two are the same for most methods.

§Examples

use indexmap::IndexSet;

// Collects which letters appear in a sentence.
let letters: IndexSet<_> = "a short treatise on fungi".chars().collect();

assert!(letters.contains(&'s'));
assert!(letters.contains(&'t'));
assert!(letters.contains(&'u'));
assert!(!letters.contains(&'y'));

Source§

Source

Create a new set. (Does not allocate.)

Source

Create a new set with capacity for n elements. (Does not allocate if n is zero.)

Computes in O(n) time.

Source§

Source

Create a new set with capacity for n elements. (Does not allocate if n is zero.)

Computes in O(n) time.

Source

Create a new set with hash_builder.

This function is const, so it can be called in static contexts.

Source

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

This number is a lower bound; the set might be able to hold more, but is guaranteed to be able to hold at least this many.

Computes in O(1) time.

Source

Return a reference to the set’s BuildHasher.

Source

Return the number of elements in the set.

Computes in O(1) time.

Source

Returns true if the set contains no elements.

Computes in O(1) time.

Source

Return an iterator over the values of the set, in their order

Source

Remove all elements in the set, while preserving its capacity.

Computes in O(n) time.

Source

Shortens the set, keeping the first len elements and dropping the rest.

If len is greater than the set’s current length, this has no effect.

Source

Clears the IndexSet in the given index range, returning those values as a drain iterator.

The range may be any type that implements RangeBounds, including all of the std::ops::Range* types, or even a tuple pair ofBound start and end values. To drain the set entirely, use RangeFulllike set.drain(..).

This shifts down all entries following the drained range to fill the gap, and keeps the allocated memory for reuse.

Panics if the starting point is greater than the end point or if the end point is greater than the length of the set.

Creates an iterator which uses a closure to determine if a value should be removed, for all values in the given range.

If the closure returns true, then the value is removed and yielded. If the closure returns false, the value will remain in the list and will not be yielded by the iterator.

The range may be any type that implements RangeBounds, including all of the std::ops::Range* types, or even a tuple pair ofBound start and end values. To check the entire set, use RangeFulllike set.extract_if(.., predicate).

If the returned ExtractIf is not exhausted, e.g. because it is dropped without iterating or the iteration short-circuits, then the remaining elements will be retained. Use retain with a negated predicate if you do not need the returned iterator.

Panics if the starting point is greater than the end point or if the end point is greater than the length of the set.

§Examples

Splitting a set into even and odd values, reusing the original set:

use indexmap::IndexSet;

let mut set: IndexSet<i32> = (0..8).collect();
let extracted: IndexSet<i32> = set.extract_if(.., |v| v % 2 == 0).collect();

let evens = extracted.into_iter().collect::<Vec<_>>();
let odds = set.into_iter().collect::<Vec<_>>();

assert_eq!(evens, vec![0, 2, 4, 6]);
assert_eq!(odds, vec![1, 3, 5, 7]);

Source

Splits the collection into two at the given index.

Returns a newly allocated set containing the elements in the range[at, len). After the call, the original set will be left containing the elements [0, at) with its previous capacity unchanged.

Panics if at > len.

Source

Reserve capacity for additional more values.

Computes in O(n) time.

Source

Reserve capacity for additional more values, without over-allocating.

Unlike reserve, this does not deliberately over-allocate the entry capacity to avoid frequent re-allocations. However, the underlying data structures may still have internal capacity requirements, and the allocator itself may give more space than requested, so this cannot be relied upon to be precisely minimal.

Computes in O(n) time.

Source

Try to reserve capacity for additional more values.

Computes in O(n) time.

Source

Try to reserve capacity for additional more values, without over-allocating.

Unlike try_reserve, this does not deliberately over-allocate the entry capacity to avoid frequent re-allocations. However, the underlying data structures may still have internal capacity requirements, and the allocator itself may give more space than requested, so this cannot be relied upon to be precisely minimal.

Computes in O(n) time.

Source

Shrink the capacity of the set as much as possible.

Computes in O(n) time.

Source

Shrink the capacity of the set with a lower limit.

Computes in O(n) time.

Source§

Source

Insert the value into the set.

If an equivalent item already exists in the set, it returnsfalse leaving the original value in the set and without altering its insertion order. Otherwise, it inserts the new item and returns true.

Computes in O(1) time (amortized average).

Source

Insert the value into the set, and get its index.

If an equivalent item already exists in the set, it returns the index of the existing item and false, leaving the original value in the set and without altering its insertion order. Otherwise, it inserts the new item and returns the index of the inserted item and true.

Computes in O(1) time (amortized average).

Source

Insert the value into the set at its ordered position among sorted values.

This is equivalent to finding the position withbinary_search, and if needed callinginsert_before for a new value.

If the sorted item is found in the set, it returns the index of that existing item and false, without any change. Otherwise, it inserts the new item and returns its sorted index and true.

If the existing items are not already sorted, then the insertion index is unspecified (like slice::binary_search), but the value is moved to or inserted at that position regardless.

Computes in O(n) time (average). Instead of repeating calls toinsert_sorted, it may be faster to call batched insertor extend and only call sort orsort_unstable once.

Source

Insert the value into the set at its ordered position among values sorted by cmp.

This is equivalent to finding the position withbinary_search_by, then callinginsert_before.

If the existing items are not already sorted, then the insertion index is unspecified (like slice::binary_search), but the value is moved to or inserted at that position regardless.

Computes in O(n) time (average).

Source

Insert the value into the set at its ordered position among values using a sort-key extraction function.

This is equivalent to finding the position withbinary_search_by_key with sort_key(key), then calling insert_before.

If the existing items are not already sorted, then the insertion index is unspecified (like slice::binary_search), but the value is moved to or inserted at that position regardless.

Computes in O(n) time (average).

Source

Insert the value into the set before the value at the given index, or at the end.

If an equivalent item already exists in the set, it returns false leaving the original value in the set, but moved to the new position. The returned index will either be the given index or one less, depending on how the value moved. (See shift_insert for different behavior here.)

Otherwise, it inserts the new value exactly at the given index and returns true.

Panics if index is out of bounds. Valid indices are 0..=set.len() (inclusive).

Computes in O(n) time (average).

§Examples
use indexmap::IndexSet;
let mut set: IndexSet<char> = ('a'..='z').collect();

// The new value '*' goes exactly at the given index.
assert_eq!(set.get_index_of(&'*'), None);
assert_eq!(set.insert_before(10, '*'), (10, true));
assert_eq!(set.get_index_of(&'*'), Some(10));

// Moving the value 'a' up will shift others down, so this moves *before* 10 to index 9.
assert_eq!(set.insert_before(10, 'a'), (9, false));
assert_eq!(set.get_index_of(&'a'), Some(9));
assert_eq!(set.get_index_of(&'*'), Some(10));

// Moving the value 'z' down will shift others up, so this moves to exactly 10.
assert_eq!(set.insert_before(10, 'z'), (10, false));
assert_eq!(set.get_index_of(&'z'), Some(10));
assert_eq!(set.get_index_of(&'*'), Some(11));

// Moving or inserting before the endpoint is also valid.
assert_eq!(set.len(), 27);
assert_eq!(set.insert_before(set.len(), '*'), (26, false));
assert_eq!(set.get_index_of(&'*'), Some(26));
assert_eq!(set.insert_before(set.len(), '+'), (27, true));
assert_eq!(set.get_index_of(&'+'), Some(27));
assert_eq!(set.len(), 28);

Source

Insert the value into the set at the given index.

If an equivalent item already exists in the set, it returns false leaving the original value in the set, but moved to the given index. Note that existing values cannot be moved to index == set.len()! (See insert_before for different behavior here.)

Otherwise, it inserts the new value at the given index and returns true.

Panics if index is out of bounds. Valid indices are 0..set.len() (exclusive) when moving an existing value, or0..=set.len() (inclusive) when inserting a new value.

Computes in O(n) time (average).

§Examples
use indexmap::IndexSet;
let mut set: IndexSet<char> = ('a'..='z').collect();

// The new value '*' goes exactly at the given index.
assert_eq!(set.get_index_of(&'*'), None);
assert_eq!(set.shift_insert(10, '*'), true);
assert_eq!(set.get_index_of(&'*'), Some(10));

// Moving the value 'a' up to 10 will shift others down, including the '*' that was at 10.
assert_eq!(set.shift_insert(10, 'a'), false);
assert_eq!(set.get_index_of(&'a'), Some(10));
assert_eq!(set.get_index_of(&'*'), Some(9));

// Moving the value 'z' down to 9 will shift others up, including the '*' that was at 9.
assert_eq!(set.shift_insert(9, 'z'), false);
assert_eq!(set.get_index_of(&'z'), Some(9));
assert_eq!(set.get_index_of(&'*'), Some(10));

// Existing values can move to len-1 at most, but new values can insert at the endpoint.
assert_eq!(set.len(), 27);
assert_eq!(set.shift_insert(set.len() - 1, '*'), false);
assert_eq!(set.get_index_of(&'*'), Some(26));
assert_eq!(set.shift_insert(set.len(), '+'), true);
assert_eq!(set.get_index_of(&'+'), Some(27));
assert_eq!(set.len(), 28);

use indexmap::IndexSet;
let mut set: IndexSet<char> = ('a'..='z').collect();

// This is an invalid index for moving an existing value!
set.shift_insert(set.len(), 'a');

Source

Adds a value to the set, replacing the existing value, if any, that is equal to the given one, without altering its insertion order. Returns the replaced value.

Computes in O(1) time (average).

Source

Adds a value to the set, replacing the existing value, if any, that is equal to the given one, without altering its insertion order. Returns the index of the item and its replaced value.

Computes in O(1) time (average).

Source

Replaces the value at the given index. The new value does not need to be equivalent to the one it is replacing, but it must be unique to the rest of the set.

Returns Ok(old_value) if successful, or Err((other_index, value)) if an equivalent value already exists at a different index. The set will be unchanged in the error case.

Panics if index is out of bounds.

Computes in O(1) time (average).

Source

Return an iterator over the values that are in self but not other.

Values are produced in the same order that they appear in self.

Source

Return an iterator over the values that are in self or other, but not in both.

Values from self are produced in their original order, followed by values from other in their original order.

Source

Return an iterator over the values that are in both self and other.

Values are produced in the same order that they appear in self.

Source

Return an iterator over all values that are in self or other.

Values from self are produced in their original order, followed by values that are unique to other in their original order.

Source

Creates a splicing iterator that replaces the specified range in the set with the given replace_with iterator and yields the removed items.replace_with does not need to be the same length as range.

The range is removed even if the iterator is not consumed until the end. It is unspecified how many elements are removed from the set if theSplice value is leaked.

The input iterator replace_with is only consumed when the Splicevalue is dropped. If a value from the iterator matches an existing entry in the set (outside of range), then the original will be unchanged. Otherwise, the new value will be inserted in the replaced range.

Panics if the starting point is greater than the end point or if the end point is greater than the length of the set.

§Examples
use indexmap::IndexSet;

let mut set = IndexSet::from([0, 1, 2, 3, 4]);
let new = [5, 4, 3, 2, 1];
let removed: Vec<_> = set.splice(2..4, new).collect();

// 1 and 4 kept their positions, while 5, 3, and 2 were newly inserted.
assert!(set.into_iter().eq([0, 1, 5, 3, 2, 4]));
assert_eq!(removed, &[2, 3]);

Source

Moves all values from other into self, leaving other empty.

This is equivalent to calling insert for each value from other in order, which means that values that already exist in self are unchanged in their current position.

See also union to iterate the combined values by reference, without modifying self or other.

§Examples
use indexmap::IndexSet;

let mut a = IndexSet::from([3, 2, 1]);
let mut b = IndexSet::from([3, 4, 5]);
let old_capacity = b.capacity();

a.append(&mut b);

assert_eq!(a.len(), 5);
assert_eq!(b.len(), 0);
assert_eq!(b.capacity(), old_capacity);

assert!(a.iter().eq(&[3, 2, 1, 4, 5]));

Source§

Source

Return true if an equivalent to value exists in the set.

Computes in O(1) time (average).

Source

Return a reference to the value stored in the set, if it is present, else None.

Computes in O(1) time (average).

Source

Return item index and value

Source

Return item index, if it exists in the set

Computes in O(1) time (average).

Source

👎Deprecated: remove disrupts the set order – use swap_remove or shift_remove for explicit behavior.

Remove the value from the set, and return true if it was present.

NOTE: This is equivalent to .swap_remove(value), replacing this value’s position with the last element, and it is deprecated in favor of calling that explicitly. If you need to preserve the relative order of the values in the set, use.shift_remove(value) instead.

Source

Remove the value from the set, and return true if it was present.

Like Vec::swap_remove, the value is removed by swapping it with the last element of the set and popping it off. This perturbs the position of what used to be the last element!

Return false if value was not in the set.

Computes in O(1) time (average).

Source

Remove the value from the set, and return true if it was present.

Like Vec::remove, the value is removed by shifting all of the elements that follow it, preserving their relative order.This perturbs the index of all of those elements!

Return false if value was not in the set.

Computes in O(n) time (average).

Source

👎Deprecated: take disrupts the set order – use swap_take or shift_take for explicit behavior.

Removes and returns the value in the set, if any, that is equal to the given one.

NOTE: This is equivalent to .swap_take(value), replacing this value’s position with the last element, and it is deprecated in favor of calling that explicitly. If you need to preserve the relative order of the values in the set, use.shift_take(value) instead.

Source

Removes and returns the value in the set, if any, that is equal to the given one.

Like Vec::swap_remove, the value is removed by swapping it with the last element of the set and popping it off. This perturbs the position of what used to be the last element!

Return None if value was not in the set.

Computes in O(1) time (average).

Source

Removes and returns the value in the set, if any, that is equal to the given one.

Like Vec::remove, the value is removed by shifting all of the elements that follow it, preserving their relative order.This perturbs the index of all of those elements!

Return None if value was not in the set.

Computes in O(n) time (average).

Source

Remove the value from the set return it and the index it had.

Like Vec::swap_remove, the value is removed by swapping it with the last element of the set and popping it off. This perturbs the position of what used to be the last element!

Return None if value was not in the set.

Source

Remove the value from the set return it and the index it had.

Like Vec::remove, the value is removed by shifting all of the elements that follow it, preserving their relative order.This perturbs the index of all of those elements!

Return None if value was not in the set.

Source§

Source

Remove the last value

This preserves the order of the remaining elements.

Computes in O(1) time (average).

Source

Removes and returns the last value from a set if the predicate returns true, or None if the predicate returns false or the set is empty (the predicate will not be called in that case).

This preserves the order of the remaining elements.

Computes in O(1) time (average).

§Examples
use indexmap::IndexSet;

let mut set = IndexSet::from([1, 2, 3, 4]);
let pred = |x: &i32| *x % 2 == 0;

assert_eq!(set.pop_if(pred), Some(4));
assert_eq!(set.as_slice(), &[1, 2, 3]);
assert_eq!(set.pop_if(pred), None);

Source

Scan through each value in the set and keep those where the closure keep returns true.

The elements are visited in order, and remaining elements keep their order.

Computes in O(n) time (average).

Source

Sort the set’s values by their default ordering.

This is a stable sort – but equivalent values should not normally coexist in a set at all, so sort_unstable is preferred because it is generally faster and doesn’t allocate auxiliary memory.

See sort_by for details.

Source

Sort the set’s values in place using the comparison function cmp.

Computes in O(n log n) time and O(n) space. The sort is stable.

Source

Sort the values of the set and return a by-value iterator of the values with the result.

The sort is stable.

Source

Sort the set’s values in place using a key extraction function.

Computes in O(n log n) time and O(n) space. The sort is stable.

Source

Sort the set’s values by their default ordering.

See sort_unstable_by for details.

Source

Sort the set’s values in place using the comparison function cmp.

Computes in O(n log n) time. The sort is unstable.

Source

Sort the values of the set and return a by-value iterator of the values with the result.

Source

Sort the set’s values in place using a key extraction function.

Computes in O(n log n) time. The sort is unstable.

Source

Sort the set’s values in place using a key extraction function.

During sorting, the function is called at most once per entry, by using temporary storage to remember the results of its evaluation. The order of calls to the function is unspecified and may change between versions of indexmap or the standard library.

Computes in O(m n + n log n + c) time () and O(n) space, where the function isO(m), n is the length of the map, and c the capacity. The sort is stable.

Source

Search over a sorted set for a value.

Returns the position where that value is present, or the position where it can be inserted to maintain the sort. See slice::binary_search for more details.

Computes in O(log(n)) time, which is notably less scalable than looking the value up using get_index_of, but this can also position missing values.

Source

Search over a sorted set with a comparator function.

Returns the position where that value is present, or the position where it can be inserted to maintain the sort. See slice::binary_search_by for more details.

Computes in O(log(n)) time.

Source

Search over a sorted set with an extraction function.

Returns the position where that value is present, or the position where it can be inserted to maintain the sort. See slice::binary_search_by_key for more details.

Computes in O(log(n)) time.

Source

Checks if the values of this set are sorted.

Source

Checks if this set is sorted using the given comparator function.

Source

Checks if this set is sorted using the given sort-key function.

Source

Returns the index of the partition point of a sorted set according to the given predicate (the index of the first element of the second partition).

See slice::partition_point for more details.

Computes in O(log(n)) time.

Source

Reverses the order of the set’s values in place.

Computes in O(n) time and O(1) space.

Source

Returns a slice of all the values in the set.

Computes in O(1) time.

Source

Converts into a boxed slice of all the values in the set.

Note that this will drop the inner hash table and any excess capacity.

Source

Get a value by index

Valid indices are 0 <= index < self.len().

Computes in O(1) time.

Source

Returns a slice of values in the given range of indices.

Valid indices are 0 <= index < self.len().

Computes in O(1) time.

Source

Get the first value

Computes in O(1) time.

Source

Get the last value

Computes in O(1) time.

Source

Remove the value by index

Valid indices are 0 <= index < self.len().

Like Vec::swap_remove, the value is removed by swapping it with the last element of the set and popping it off. This perturbs the position of what used to be the last element!

Computes in O(1) time (average).

Source

Remove the value by index

Valid indices are 0 <= index < self.len().

Like Vec::remove, the value is removed by shifting all of the elements that follow it, preserving their relative order.This perturbs the index of all of those elements!

Computes in O(n) time (average).

Source

Moves the position of a value from one index to another by shifting all other values in-between.

Panics if from or to are out of bounds.

Computes in O(n) time (average).

Source

Swaps the position of two values in the set.

Panics if a or b are out of bounds.

Computes in O(1) time (average).

Source§

Source

Returns true if self has no elements in common with other.

Source

Returns true if all elements of self are contained in other.

Source

Returns true if all elements of other are contained in self.

Source§

Parallel iterator methods and other parallel methods.

The following methods require crate feature "rayon".

See also the IntoParallelIterator implementations.

Source

Available on crate feature rayon only.

Return a parallel iterator over the values that are in self but not other.

While parallel iterators can process items in any order, their relative order in the self set is still preserved for operations like reduce and collect.

Source

Available on crate feature rayon only.

Return a parallel iterator over the values that are in self or other, but not in both.

While parallel iterators can process items in any order, their relative order in the sets is still preserved for operations like reduce and collect. Values from self are produced in their original order, followed by values from other in their original order.

Source

Available on crate feature rayon only.

Return a parallel iterator over the values that are in both self and other.

While parallel iterators can process items in any order, their relative order in the self set is still preserved for operations like reduce and collect.

Source

Available on crate feature rayon only.

Return a parallel iterator over all values that are in self or other.

While parallel iterators can process items in any order, their relative order in the sets is still preserved for operations like reduce and collect. Values from self are produced in their original order, followed by values that are unique to other in their original order.

Source

Available on crate feature rayon only.

Returns true if self contains all of the same values as other, regardless of each set’s indexed order, determined in parallel.

Source

Available on crate feature rayon only.

Returns true if self has no elements in common with other, determined in parallel.

Source

Available on crate feature rayon only.

Returns true if all elements of other are contained in self, determined in parallel.

Source

Available on crate feature rayon only.

Returns true if all elements of self are contained in other, determined in parallel.

Source§

Parallel sorting methods.

The following methods require crate feature "rayon".

Source

Available on crate feature rayon only.

Sort the set’s values in parallel by their default ordering.

Source

Available on crate feature rayon only.

Sort the set’s values in place and in parallel, using the comparison function cmp.

Source

Available on crate feature rayon only.

Sort the values of the set in parallel and return a by-value parallel iterator of the values with the result.

Source

Available on crate feature rayon only.

Sort the set’s values in place and in parallel, using a key extraction function.

Source

Available on crate feature rayon only.

Sort the set’s values in parallel by their default ordering.

Source

Available on crate feature rayon only.

Sort the set’s values in place and in parallel, using the comparison function cmp.

Source

Available on crate feature rayon only.

Sort the values of the set in parallel and return a by-value parallel iterator of the values with the result.

Source

Available on crate feature rayon only.

Sort the set’s values in place and in parallel, using a key extraction function.

Source

Available on crate feature rayon only.

Sort the set’s values in place and in parallel, using a key extraction function.

Source§

Available on crate feature arbitrary only.

Source§

Generate an arbitrary value of Self from the given unstructured data. Read more

Source§

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more

Source§

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more

Source§

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more

Source§

Available on crate feature quickcheck only.

Source§

Source§

Returns the set intersection, cloned into a new set.

Values are collected in the same order that they appear in self.

Source§

The resulting type after applying the & operator.

Source§

Source§

Returns the set union, cloned into a new set.

Values from self are collected in their original order, followed by values that are unique to other in their original order.

Source§

The resulting type after applying the | operator.

Source§

Source§

Returns the set symmetric-difference, cloned into a new set.

Values from self are collected in their original order, followed by values from other in their original order.

Source§

The resulting type after applying the ^ operator.

Source§

Available on crate feature borsh only.

👎Deprecated: use borsh's indexmap feature instead.

Source§

Source§

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.

Source§

Deserialize this instance from a slice of bytes.

Source§

Source§

Available on crate feature borsh only.

👎Deprecated: use borsh's indexmap feature instead.

Source§

Source§

Source§

Source§

Source§

Available on crate feature serde only.

Source§

Source§

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

Source§

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

Extends a collection with exactly one element.

Source§

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

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

Source§

Source§

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

Source§

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

Extends a collection with exactly one element.

Source§

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

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

Source§

Source§

§Examples
use indexmap::IndexSet;

let set1 = IndexSet::from([1, 2, 3, 4]);
let set2: IndexSet<_> = [1, 2, 3, 4].into();
assert_eq!(set1, set2);

Source§

Source§

Available on crate feature rayon only.

Source§

Creates an instance of the collection from the parallel iterator par_iter. Read more

Source§

Source§

The returned type after indexing.

Source§

Performs the indexing (container[index]) operation. Read more

Source§

Source§

The returned type after indexing.

Source§

Performs the indexing (container[index]) operation. Read more

Source§

Source§

The returned type after indexing.

Source§

Performs the indexing (container[index]) operation. Read more

Source§

Source§

The returned type after indexing.

Source§

Performs the indexing (container[index]) operation. Read more

Source§

Source§

The returned type after indexing.

Source§

Performs the indexing (container[index]) operation. Read more

Source§

Source§

The returned type after indexing.

Source§

Performs the indexing (container[index]) operation. Read more

Source§

Source§

The returned type after indexing.

Source§

Performs the indexing (container[index]) operation. Read more

Source§

Access IndexSet values at indexed positions.

§Examples

use indexmap::IndexSet;

let mut set = IndexSet::new();
for word in "Lorem ipsum dolor sit amet".split_whitespace() {
    set.insert(word.to_string());
}
assert_eq!(set[0], "Lorem");
assert_eq!(set[1], "ipsum");
set.reverse();
assert_eq!(set[0], "amet");
assert_eq!(set[1], "sit");
set.sort();
assert_eq!(set[0], "Lorem");
assert_eq!(set[1], "amet");

use indexmap::IndexSet;

let mut set = IndexSet::new();
set.insert("foo");
println!("{:?}", set[10]); // panics!

Source§

Returns a reference to the value at the supplied index.

Panics if index is out of bounds.

Source§

The returned type after indexing.

Source§

Available on crate feature serde only.

Source§

The type of the deserializer being converted into.

Source§

Convert this value into a deserializer.

Source§

Source§

The type of the elements being iterated over.

Source§

Which kind of iterator are we turning this into?

Source§

Creates an iterator from a value. Read more

Source§

Source§

The type of the elements being iterated over.

Source§

Which kind of iterator are we turning this into?

Source§

Creates an iterator from a value. Read more

Source§

Available on crate feature rayon only.

Source§

The type of item that the parallel iterator will produce.

Source§

The parallel iterator type that will be created.

Source§

Converts self into a parallel iterator. Read more

Source§

Available on crate feature rayon only.

Source§

The type of item that the parallel iterator will produce.

Source§

The parallel iterator type that will be created.

Source§

Converts self into a parallel iterator. Read more

Source§

Opt-in mutable access to IndexSet values.

Source§

Available on crate feature rayon only.

Source§

The type of item that the parallel iterator will produce. This is usually the same as IntoParallelIterator::Item.

Source§

The draining parallel iterator type that will be created.

Source§

Returns a draining parallel iterator over a range of the collection. Read more

Source§

Available on crate feature rayon only.

Source§

Extends an instance of the collection with the elements drawn from the parallel iterator par_iter. Read more

Source§

Available on crate feature rayon only.

Source§

Extends an instance of the collection with the elements drawn from the parallel iterator par_iter. Read more

Source§

Source§

Tests for self and other values to be equal, and is used by ==.

1.0.0 · Source§

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Source§

Available on crate feature serde only.

Source§

Source§

Returns the set difference, cloned into a new set.

Values are collected in the same order that they appear in self.

Source§

The resulting type after applying the - operator.

Source§

Available on crate feature sval only.

Source§

Stream this value through a Stream.

Source§

Get the tag of this value, if there is one.

Source§

Try convert this value into a boolean.

Source§

Try convert this value into a 32bit binary floating point number.

Source§

Try convert this value into a 64bit binary floating point number.

Source§

Try convert this value into a signed 8bit integer.

Source§

Try convert this value into a signed 16bit integer.

Source§

Try convert this value into a signed 32bit integer.

Source§

Try convert this value into a signed 64bit integer.

Source§

Try convert this value into a signed 128bit integer.

Source§

Try convert this value into an unsigned 8bit integer.

Source§

Try convert this value into an unsigned 16bit integer.

Source§

Try convert this value into an unsigned 32bit integer.

Source§

Try convert this value into an unsigned 64bit integer.

Source§

Try convert this value into an unsigned 128bit integer.

Source§

Try convert this value into a text string.

Source§

Try convert this value into a bitstring.

Source§