Struct oxygengine_core::ecs::hibitset::AtomicBitSet [−]
pub struct AtomicBitSet { /* fields omitted */ }Expand description
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
impl AtomicBitSetpub fn new() -> AtomicBitSet
pub fn new() -> AtomicBitSetCreates an empty AtomicBitSet.
pub fn add_atomic(&self, id: u32) -> bool
pub fn add_atomic(&self, id: u32) -> boolAdds 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.
Adds id to the BitSet. Returns true if the value was
already in the set.
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 clear(&mut self)
pub fn clear(&mut self)Clear all bits in the set
Trait Implementations
impl<'a, T> BitAnd<T> for &'a AtomicBitSet where
T: BitSetLike,
impl<'a, T> BitAnd<T> for &'a AtomicBitSet where
T: BitSetLike, type Output = BitSetAnd<&'a AtomicBitSet, T>
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
pub fn bitand(self, rhs: T) -> <&'a AtomicBitSet as BitAnd<T>>::OutputPerforms the & operation. Read more
impl<T> BitAnd<T> for AtomicBitSet where
T: BitSetLike,
impl<T> BitAnd<T> for AtomicBitSet where
T: BitSetLike, type Output = BitSetAnd<AtomicBitSet, T>
type Output = BitSetAnd<AtomicBitSet, T>The resulting type after applying the & operator.
pub fn bitand(self, rhs: T) -> <AtomicBitSet as BitAnd<T>>::Output
pub fn bitand(self, rhs: T) -> <AtomicBitSet as BitAnd<T>>::OutputPerforms the & operation. Read more
impl<'a, T> BitOr<T> for &'a AtomicBitSet where
T: BitSetLike,
impl<'a, T> BitOr<T> for &'a AtomicBitSet where
T: BitSetLike, type Output = BitSetOr<&'a AtomicBitSet, T>
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
pub fn bitor(self, rhs: T) -> <&'a AtomicBitSet as BitOr<T>>::OutputPerforms the | operation. Read more
impl<T> BitOr<T> for AtomicBitSet where
T: BitSetLike,
impl<T> BitOr<T> for AtomicBitSet where
T: BitSetLike, type Output = BitSetOr<AtomicBitSet, T>
type Output = BitSetOr<AtomicBitSet, T>The resulting type after applying the | operator.
pub fn bitor(self, rhs: T) -> <AtomicBitSet as BitOr<T>>::Output
pub fn bitor(self, rhs: T) -> <AtomicBitSet as BitOr<T>>::OutputPerforms the | operation. Read more
impl BitSetLike for AtomicBitSet
impl BitSetLike for AtomicBitSetReturn a usize where each bit represents if any word in layer2
has been set. Read more
Return the usize from the array of usizes that indicates if any
bit has been set in layer1 Read more
Return the usize from the array of usizes that indicates if any
bit has been set in layer0 Read more
Return a usize that maps to the direct 1:1 association with
each index of the set Read more
fn get_from_layer(&self, layer: usize, idx: usize) -> usize
fn get_from_layer(&self, layer: usize, idx: usize) -> usizeGets the usize corresponding to layer and index. Read more
impl<'a, T> BitXor<T> for &'a AtomicBitSet where
T: BitSetLike,
impl<'a, T> BitXor<T> for &'a AtomicBitSet where
T: BitSetLike, type Output = BitSetXor<&'a AtomicBitSet, T>
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
pub fn bitxor(self, rhs: T) -> <&'a AtomicBitSet as BitXor<T>>::OutputPerforms the ^ operation. Read more
impl<T> BitXor<T> for AtomicBitSet where
T: BitSetLike,
impl<T> BitXor<T> for AtomicBitSet where
T: BitSetLike, type Output = BitSetXor<AtomicBitSet, T>
type Output = BitSetXor<AtomicBitSet, T>The resulting type after applying the ^ operator.
pub fn bitxor(self, rhs: T) -> <AtomicBitSet as BitXor<T>>::Output
pub fn bitxor(self, rhs: T) -> <AtomicBitSet as BitXor<T>>::OutputPerforms the ^ operation. Read more
impl Debug for AtomicBitSet
impl Debug for AtomicBitSetimpl Default for AtomicBitSet
impl Default for AtomicBitSetpub fn default() -> AtomicBitSet
pub fn default() -> AtomicBitSetReturns the “default value” for a type. Read more
impl DrainableBitSet for AtomicBitSet
impl DrainableBitSet for AtomicBitSetfn 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;
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;Create a draining iterator that will scan over the keyspace and clears it while doing so.
impl<'a> Extend<&'a u32> for AtomicBitSet
impl<'a> Extend<&'a u32> for AtomicBitSetpub fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = &'a u32>,
pub fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = &'a u32>, Extends a collection with the contents of an iterator. Read more
extend_one)Extends a collection with exactly one element.
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
impl Extend<u32> for AtomicBitSet
impl Extend<u32> for AtomicBitSetpub fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = u32>,
pub fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = u32>, Extends a collection with the contents of an iterator. Read more
extend_one)Extends a collection with exactly one element.
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
impl<'a> FromIterator<&'a u32> for AtomicBitSet
impl<'a> FromIterator<&'a u32> for AtomicBitSetpub fn from_iter<T>(iter: T) -> AtomicBitSet where
T: IntoIterator<Item = &'a u32>,
pub fn from_iter<T>(iter: T) -> AtomicBitSet where
T: IntoIterator<Item = &'a u32>, Creates a value from an iterator. Read more
impl FromIterator<u32> for AtomicBitSet
impl FromIterator<u32> for AtomicBitSetpub fn from_iter<T>(iter: T) -> AtomicBitSet where
T: IntoIterator<Item = u32>,
pub fn from_iter<T>(iter: T) -> AtomicBitSet where
T: IntoIterator<Item = u32>, Creates a value from an iterator. Read more
impl<'a> IntoIterator for &'a AtomicBitSet
impl<'a> IntoIterator for &'a AtomicBitSettype Item = <BitIter<&'a AtomicBitSet> as Iterator>::Item
type Item = <BitIter<&'a AtomicBitSet> as Iterator>::ItemThe type of the elements being iterated over.
type IntoIter = BitIter<&'a AtomicBitSet>
type IntoIter = BitIter<&'a AtomicBitSet>Which kind of iterator are we turning this into?
pub fn into_iter(self) -> <&'a AtomicBitSet as IntoIterator>::IntoIter
pub fn into_iter(self) -> <&'a AtomicBitSet as IntoIterator>::IntoIterCreates an iterator from a value. Read more
impl IntoIterator for AtomicBitSet
impl IntoIterator for AtomicBitSettype Item = <BitIter<AtomicBitSet> as Iterator>::Item
type Item = <BitIter<AtomicBitSet> as Iterator>::ItemThe type of the elements being iterated over.
type IntoIter = BitIter<AtomicBitSet>
type IntoIter = BitIter<AtomicBitSet>Which kind of iterator are we turning this into?
pub fn into_iter(self) -> <AtomicBitSet as IntoIterator>::IntoIter
pub fn into_iter(self) -> <AtomicBitSet as IntoIterator>::IntoIterCreates an iterator from a value. Read more
type Mask = AtomicBitSet
type Mask = AtomicBitSetType of joined bit mask.
Open this join by returning the mask and the storages. Read more
pub unsafe fn get(
&mut <AtomicBitSet as Join>::Value,
id: u32
) -> <AtomicBitSet as Join>::Type[src]
pub unsafe fn get(
&mut <AtomicBitSet as Join>::Value,
id: u32
) -> <AtomicBitSet as Join>::Type[src]Get a joined component value by a given index. Read more
Create a joined iterator over the contents.
Returns a Join-able structure that yields all indices, returning
None for all missing elements and Some(T) for found elements. Read more
If this Join typically returns all indices in the mask, then iterating
over only it or combined with other joins that are also dangerous
will cause the JoinIter/ParJoin to go through all indices which
is usually not what is wanted and will kill performance. Read more
type Mask = &'a AtomicBitSet
type Mask = &'a AtomicBitSetType of joined bit mask.
pub unsafe fn open(
self
) -> (<&'a AtomicBitSet as Join>::Mask, <&'a AtomicBitSet as Join>::Value)[src]
pub unsafe fn open(
self
) -> (<&'a AtomicBitSet as Join>::Mask, <&'a AtomicBitSet as Join>::Value)[src]Open this join by returning the mask and the storages. Read more
pub unsafe fn get(
&mut <&'a AtomicBitSet as Join>::Value,
id: u32
) -> <&'a AtomicBitSet as Join>::Type[src]
pub unsafe fn get(
&mut <&'a AtomicBitSet as Join>::Value,
id: u32
) -> <&'a AtomicBitSet as Join>::Type[src]Get a joined component value by a given index. Read more
Create a joined iterator over the contents.
Returns a Join-able structure that yields all indices, returning
None for all missing elements and Some(T) for found elements. Read more
If this Join typically returns all indices in the mask, then iterating
over only it or combined with other joins that are also dangerous
will cause the JoinIter/ParJoin to go through all indices which
is usually not what is wanted and will kill performance. Read more
impl<'a> Not for &'a AtomicBitSet
impl<'a> Not for &'a AtomicBitSettype Output = BitSetNot<&'a AtomicBitSet>
type Output = BitSetNot<&'a AtomicBitSet>The resulting type after applying the ! operator.
pub fn not(self) -> <&'a AtomicBitSet as Not>::Output
pub fn not(self) -> <&'a AtomicBitSet as Not>::OutputPerforms the unary ! operation. Read more
impl Not for AtomicBitSet
impl Not for AtomicBitSettype Output = BitSetNot<AtomicBitSet>
type Output = BitSetNot<AtomicBitSet>The resulting type after applying the ! operator.
pub fn not(self) -> <AtomicBitSet as Not>::Output
pub fn not(self) -> <AtomicBitSet as Not>::OutputPerforms the unary ! operation. Read more
Auto Trait Implementations
impl RefUnwindSafe for AtomicBitSetimpl Send for AtomicBitSetimpl Sync for AtomicBitSetimpl Unpin for AtomicBitSetimpl UnwindSafe for AtomicBitSetBlanket Implementations
impl<T> Any for T where
T: Any,
impl<T> Any for T where
T: Any, pub fn get_type_id(&self) -> TypeIdMutably borrows from an owned value. Read more
Tries to create the default.
Calls try_default and panics on an error case.