Struct ArraySet

Source
pub struct ArraySet<K, const N: usize> { /* private fields */ }
Expand description

A set backed by an array. All possible keys must be known statically.

This set is O(1) for all operations

Implementations§

Source§

impl<K, const N: usize> ArraySet<K, N>

Source

pub const fn len(&self) -> usize

Returns the number of keys that this set currently holds

Source

pub const fn is_empty(&self) -> bool

Returns whether this set contains any keys

Source§

impl<K: Indexable, const N: usize> ArraySet<K, N>

Source

pub fn new() -> Self

Creates a new, empty ArraySet

Source

pub fn contains(&self, k: K) -> bool

Determines whether a key already exists in the set

Source

pub fn insert(&mut self, k: K) -> bool

Inserts a key into the set and returns whether it was already contained in the set

Source

pub fn remove(&mut self, k: K) -> bool

Removes a key from the set and returns whether it was already contained in the set

Source

pub fn keys(&self) -> impl Iterator<Item = K> + '_

Returns an iterator over all values that are in the set

Source

pub fn is_full(&self) -> bool

Returns whether all possible keys are in the set

Source

pub fn empty() -> Self

Creates a new, empty ArraySet

§Panics

Panics if any of the safety requirements in the Indexable trait are wrong

Source

pub fn full() -> Self

Creates a new, full ArraySet

Source

pub fn unset_keys(&self) -> usize

Returns the number of keys that aren’t in the set

Source§

impl<K: ReverseIndexable, const N: usize> ArraySet<K, N>

Source

pub fn fast_keys(&self) -> impl Iterator<Item = K> + '_

Returns an iterator over all values that are in the set

Source§

impl<K: Indexable> ArraySet<K, 1>

Source

pub fn to_int<U>(self) -> U
where u8: Into<U>,

Returns this set as a u8 (or anything that it can be turned into) with the appropriate bits representing each of the keys in this set.

Source

pub fn from_int(u: u8) -> Self

Creates a new ArraySet from the given u8. Bits may be cleared to ensure this is in a valid state.

Source§

impl<K: Indexable> ArraySet<K, 2>

Source

pub fn to_int<U>(self) -> U
where u16: Into<U>,

Returns this set as a u16 (or anything that it can be turned into) with the appropriate bits representing each of the keys in this set.

Source

pub fn from_int(u: u16) -> Self

Creates a new ArraySet from the given u16. Bits may be cleared to ensure this is in a valid state.

Source§

impl<K: Indexable> ArraySet<K, 3>

Source

pub fn to_int<U>(self) -> U
where u32: Into<U>,

Returns this set as a u32 (or anything that it can be turned into) with the appropriate bits representing each of the keys in this set.

Source

pub fn from_int(u: u32) -> Self

Creates a new ArraySet from the given u32. Bits may be cleared to ensure this is in a valid state.

Source§

impl<K: Indexable> ArraySet<K, 4>

Source

pub fn to_int<U>(self) -> U
where u32: Into<U>,

Returns this set as a u32 (or anything that it can be turned into) with the appropriate bits representing each of the keys in this set.

Source

pub fn from_int(u: u32) -> Self

Creates a new ArraySet from the given u32. Bits may be cleared to ensure this is in a valid state.

Source§

impl<K: Indexable> ArraySet<K, 5>

Source

pub fn to_int<U>(self) -> U
where u64: Into<U>,

Returns this set as a u64 (or anything that it can be turned into) with the appropriate bits representing each of the keys in this set.

Source

pub fn from_int(u: u64) -> Self

Creates a new ArraySet from the given u64. Bits may be cleared to ensure this is in a valid state.

Source§

impl<K: Indexable> ArraySet<K, 6>

Source

pub fn to_int<U>(self) -> U
where u64: Into<U>,

Returns this set as a u64 (or anything that it can be turned into) with the appropriate bits representing each of the keys in this set.

Source

pub fn from_int(u: u64) -> Self

Creates a new ArraySet from the given u64. Bits may be cleared to ensure this is in a valid state.

Source§

impl<K: Indexable> ArraySet<K, 7>

Source

pub fn to_int<U>(self) -> U
where u64: Into<U>,

Returns this set as a u64 (or anything that it can be turned into) with the appropriate bits representing each of the keys in this set.

Source

pub fn from_int(u: u64) -> Self

Creates a new ArraySet from the given u64. Bits may be cleared to ensure this is in a valid state.

Source§

impl<K: Indexable> ArraySet<K, 8>

Source

pub fn to_int<U>(self) -> U
where u64: Into<U>,

Returns this set as a u64 (or anything that it can be turned into) with the appropriate bits representing each of the keys in this set.

Source

pub fn from_int(u: u64) -> Self

Creates a new ArraySet from the given u64. Bits may be cleared to ensure this is in a valid state.

Trait Implementations§

Source§

impl<K: Indexable, const N: usize> Add<K> for ArraySet<K, N>

Source§

type Output = ArraySet<K, N>

The resulting type after applying the + operator.
Source§

fn add(self, k: K) -> Self::Output

Performs the + operation. Read more
Source§

impl<K: Indexable, const N: usize> Add for ArraySet<K, N>

Source§

type Output = ArraySet<K, N>

The resulting type after applying the + operator.
Source§

fn add(self, k: ArraySet<K, N>) -> Self::Output

Performs the + operation. Read more
Source§

impl<K: Indexable, const N: usize> Binary for ArraySet<K, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: Indexable, const N: usize> BitAnd for ArraySet<K, N>

Source§

type Output = ArraySet<K, N>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl<K: Indexable, const N: usize> BitAndAssign for ArraySet<K, N>

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl<K: Indexable, const N: usize> BitOr for ArraySet<K, N>

Source§

type Output = ArraySet<K, N>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl<K: Indexable, const N: usize> BitOrAssign for ArraySet<K, N>

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl<K: Indexable, const N: usize> BitXor for ArraySet<K, N>

Source§

type Output = ArraySet<K, N>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<K: Indexable, const N: usize> BitXorAssign for ArraySet<K, N>

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl<K, const N: usize> Clone for ArraySet<K, N>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug + Indexable, const N: usize> Debug for ArraySet<K, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: Indexable, const N: usize> Default for ArraySet<K, N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, K: Deserialize<'de> + Indexable, const N: usize> Deserialize<'de> for ArraySet<K, N>

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Self, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<K: Indexable, const M: usize, const S: usize> From<&ArrayMap<K, AtomicBool, M>> for ArraySet<K, S>

Source§

fn from(m: &ArrayMap<K, AtomicBool, M>) -> Self

Converts to this type from the input type.
Source§

impl<K: Indexable, const M: usize, const S: usize> From<ArrayMap<K, bool, M>> for ArraySet<K, S>

Source§

fn from(m: ArrayMap<K, bool, M>) -> Self

Converts to this type from the input type.
Source§

impl<K: Indexable, const M: usize, const S: usize> From<ArraySet<K, S>> for ArrayMap<K, AtomicBool, M>

Source§

fn from(s: ArraySet<K, S>) -> Self

Converts to this type from the input type.
Source§

impl<K: Indexable, const M: usize, const S: usize> From<ArraySet<K, S>> for ArrayMap<K, bool, M>

Source§

fn from(s: ArraySet<K, S>) -> Self

Converts to this type from the input type.
Source§

impl<K: Indexable, const N: usize> From<K> for ArraySet<K, N>

Source§

fn from(k: K) -> Self

Converts to this type from the input type.
Source§

impl<K: Indexable, const N: usize> FromIterator<K> for ArraySet<K, N>

Source§

fn from_iter<I: IntoIterator<Item = K>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<K: Indexable, const N: usize> Index<K> for ArraySet<K, N>

Source§

type Output = bool

The returned type after indexing.
Source§

fn index(&self, index: K) -> &Self::Output

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

impl<K: Indexable, const N: usize> Index<usize> for ArraySet<K, N>

Source§

type Output = bool

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

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

impl<K: Indexable, const N: usize> IntoIterator for ArraySet<K, N>

Source§

type Item = K

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<K, N>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K: Indexable, const N: usize> Not for ArraySet<K, N>

Source§

type Output = ArraySet<K, N>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<K, const N: usize> PartialEq for ArraySet<K, N>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

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

impl<K: Serialize + Indexable, const N: usize> Serialize for ArraySet<K, N>

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<K: Indexable, const N: usize> Sub<K> for ArraySet<K, N>

Source§

type Output = ArraySet<K, N>

The resulting type after applying the - operator.
Source§

fn sub(self, k: K) -> Self::Output

Performs the - operation. Read more
Source§

impl<K: Indexable, const N: usize> Sub for ArraySet<K, N>

Source§

type Output = ArraySet<K, N>

The resulting type after applying the - operator.
Source§

fn sub(self, k: ArraySet<K, N>) -> Self::Output

Performs the - operation. Read more
Source§

impl<K, const N: usize> Copy for ArraySet<K, N>

Source§

impl<K, const N: usize> Eq for ArraySet<K, N>

Source§

impl<K, const N: usize> Send for ArraySet<K, N>

Source§

impl<K, const N: usize> Sync for ArraySet<K, N>

Source§

impl<K, const N: usize> Unpin for ArraySet<K, N>

Source§

impl<K, const N: usize> UnwindSafe for ArraySet<K, N>

Auto Trait Implementations§

§

impl<K, const N: usize> Freeze for ArraySet<K, N>

§

impl<K, const N: usize> RefUnwindSafe for ArraySet<K, N>
where K: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,