Struct oxygengine_core::ecs::hibitset::AtomicBitSet [−]
This is similar to a BitSet
but allows setting of value
without unique ownership of the structure
An AtomicBitSet
has the ability to add an item to the set
without unique ownership (given that the set is big enough).
Removing elements does require unique ownership as an effect
of the hierarchy it holds. Worst case multiple writers set the
same bit twice (but only is told they set it).
It is possible to atomically remove from the set, but not at the same time as atomically adding. This is because there is no way to know if layer 1-3 would be left in a consistent state if they are being cleared and set at the same time.
AtromicBitSet
resolves this race by disallowing atomic
clearing of bits.
Implementations
impl AtomicBitSet
pub fn new() -> AtomicBitSet
Creates an empty AtomicBitSet
.
pub fn add_atomic(&self, id: u32) -> bool
Adds id
to the AtomicBitSet
. Returns true
if the value was
already in the set.
Because we cannot safely extend an AtomicBitSet without unique ownership this will panic if the Index is out of range.
pub fn add(&mut self, id: u32) -> bool
Adds id
to the BitSet
. Returns true
if the value was
already in the set.
pub fn remove(&mut self, id: u32) -> bool
Removes id
from the set, returns true
if the value
was removed, and false
if the value was not set
to begin with.
pub fn contains(&self, id: u32) -> bool
Returns true
if id
is in the set.
pub fn clear(&mut self)
Clear all bits in the set
Trait Implementations
impl<T> BitAnd<T> for AtomicBitSet where
T: BitSetLike,
T: BitSetLike,
type Output = BitSetAnd<AtomicBitSet, T>
The resulting type after applying the &
operator.
pub fn bitand(self, rhs: T) -> <AtomicBitSet as BitAnd<T>>::Output
impl<'a, T> BitAnd<T> for &'a AtomicBitSet where
T: BitSetLike,
T: BitSetLike,
type Output = BitSetAnd<&'a AtomicBitSet, T>
The resulting type after applying the &
operator.
pub fn bitand(self, rhs: T) -> <&'a AtomicBitSet as BitAnd<T>>::Output
impl<'a, T> BitOr<T> for &'a AtomicBitSet where
T: BitSetLike,
T: BitSetLike,
type Output = BitSetOr<&'a AtomicBitSet, T>
The resulting type after applying the |
operator.
pub fn bitor(self, rhs: T) -> <&'a AtomicBitSet as BitOr<T>>::Output
impl<T> BitOr<T> for AtomicBitSet where
T: BitSetLike,
T: BitSetLike,
type Output = BitSetOr<AtomicBitSet, T>
The resulting type after applying the |
operator.
pub fn bitor(self, rhs: T) -> <AtomicBitSet as BitOr<T>>::Output
impl BitSetLike for AtomicBitSet
pub fn layer3(&self) -> usize
pub fn layer2(&self, i: usize) -> usize
pub fn layer1(&self, i: usize) -> usize
pub fn layer0(&self, i: usize) -> usize
pub fn contains(&self, i: u32) -> bool
pub fn get_from_layer(&self, layer: usize, idx: usize) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(self) -> BitIter<Self>ⓘ
impl<T> BitXor<T> for AtomicBitSet where
T: BitSetLike,
T: BitSetLike,
type Output = BitSetXor<AtomicBitSet, T>
The resulting type after applying the ^
operator.
pub fn bitxor(self, rhs: T) -> <AtomicBitSet as BitXor<T>>::Output
impl<'a, T> BitXor<T> for &'a AtomicBitSet where
T: BitSetLike,
T: BitSetLike,
type Output = BitSetXor<&'a AtomicBitSet, T>
The resulting type after applying the ^
operator.
pub fn bitxor(self, rhs: T) -> <&'a AtomicBitSet as BitXor<T>>::Output
impl Debug for AtomicBitSet
impl Default for AtomicBitSet
pub fn default() -> AtomicBitSet
impl DrainableBitSet for AtomicBitSet
pub fn remove(&mut self, i: u32) -> bool
pub fn drain(&'a mut self) -> DrainBitIter<'a, Self>ⓘNotable traits for DrainBitIter<'a, T>
impl<'a, T> Iterator for DrainBitIter<'a, T> where
T: DrainableBitSet, type Item = u32;
Notable traits for DrainBitIter<'a, T>
impl<'a, T> Iterator for DrainBitIter<'a, T> where
T: DrainableBitSet, type Item = u32;
impl<'a> Extend<&'a u32> for AtomicBitSet
pub fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = &'a u32>,
T: IntoIterator<Item = &'a u32>,
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl Extend<u32> for AtomicBitSet
pub fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = u32>,
T: IntoIterator<Item = u32>,
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<'a> FromIterator<&'a u32> for AtomicBitSet
pub fn from_iter<T>(iter: T) -> AtomicBitSet where
T: IntoIterator<Item = &'a u32>,
T: IntoIterator<Item = &'a u32>,
impl FromIterator<u32> for AtomicBitSet
pub fn from_iter<T>(iter: T) -> AtomicBitSet where
T: IntoIterator<Item = u32>,
T: IntoIterator<Item = u32>,
impl IntoIterator for AtomicBitSet
type Item = <BitIter<AtomicBitSet> as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = BitIter<AtomicBitSet>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> <AtomicBitSet as IntoIterator>::IntoIter
impl<'a> IntoIterator for &'a AtomicBitSet
type Item = <BitIter<&'a AtomicBitSet> as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = BitIter<&'a AtomicBitSet>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> <&'a AtomicBitSet as IntoIterator>::IntoIter
impl<'a> Join for &'a AtomicBitSet
[src]
type Type = u32
Type of joined components.
type Value = ()
Type of joined storages.
type Mask = &'a AtomicBitSet
Type of joined bit mask.
pub unsafe fn open(
self
) -> (<&'a AtomicBitSet as Join>::Mask, <&'a AtomicBitSet as Join>::Value)
[src]
self
) -> (<&'a AtomicBitSet as Join>::Mask, <&'a AtomicBitSet as Join>::Value)
pub unsafe fn get(
&mut <&'a AtomicBitSet as Join>::Value,
id: u32
) -> <&'a AtomicBitSet as Join>::Type
[src]
&mut <&'a AtomicBitSet as Join>::Value,
id: u32
) -> <&'a AtomicBitSet as Join>::Type
pub fn join(self) -> JoinIter<Self>ⓘ
[src]
pub fn maybe(self) -> MaybeJoin<Self>
[src]
pub fn is_unconstrained() -> bool
[src]
impl Join for AtomicBitSet
[src]
type Type = u32
Type of joined components.
type Value = ()
Type of joined storages.
type Mask = AtomicBitSet
Type of joined bit mask.
pub unsafe fn open(
self
) -> (<AtomicBitSet as Join>::Mask, <AtomicBitSet as Join>::Value)
[src]
self
) -> (<AtomicBitSet as Join>::Mask, <AtomicBitSet as Join>::Value)
pub unsafe fn get(
&mut <AtomicBitSet as Join>::Value,
id: u32
) -> <AtomicBitSet as Join>::Type
[src]
&mut <AtomicBitSet as Join>::Value,
id: u32
) -> <AtomicBitSet as Join>::Type
pub fn join(self) -> JoinIter<Self>ⓘ
[src]
pub fn maybe(self) -> MaybeJoin<Self>
[src]
pub fn is_unconstrained() -> bool
[src]
impl Not for AtomicBitSet
type Output = BitSetNot<AtomicBitSet>
The resulting type after applying the !
operator.
pub fn not(self) -> <AtomicBitSet as Not>::Output
impl<'a> Not for &'a AtomicBitSet
type Output = BitSetNot<&'a AtomicBitSet>
The resulting type after applying the !
operator.
pub fn not(self) -> <&'a AtomicBitSet as Not>::Output
Auto Trait Implementations
impl RefUnwindSafe for AtomicBitSet
impl Send for AtomicBitSet
impl Sync for AtomicBitSet
impl Unpin for AtomicBitSet
impl UnwindSafe for AtomicBitSet
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
pub fn get_type_id(&self) -> TypeId
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Event for T where
T: Send + Sync + 'static,
[src]
T: Send + Sync + 'static,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Resource for T where
T: Any,
[src]
T: Any,
impl<T> TryDefault for T where
T: Default,
[src]
T: Default,
pub fn try_default() -> Result<T, String>
[src]
pub fn unwrap_default() -> Self
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,