You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The pdsl_core is currently missing an efficient and elegant way to handle bit sets.
Using a storage::Vec<bool> is very inefficient, since it would require storing every single bit in a different storage cell and using storage::Vec<[u8; 32]> (or similar) would require implementation effort from the user.
The storage::Bitset should provide the most basic functionality for sets of bits and should be very efficient in the way that it reduces contract storage access to a minimum while keeping up with overall performance.
Bits stored in the storage::Bitset should be bundled - for example as [u8; 32]. This allows efficient contract storage access and lots of cache efficiency on the memory side.
A storage::Bitset should allow iteration and the following APIs:
symmetric_difference(&mut self, other: &Bitset) *
difference(&mut self, other: &Bitset) *
union(&mut self, other: &Bitset) *
intersection(&mut self, other: &Bitset) *
(*) Means that this API is not final.
is_disjoint(&self, other: &Bitset) -> bool
is_subset(&self, other: &Bitset) -> bool
is_superset(&self, other: &Bitset) -> bool
len(&self) -> u32
is_empty(&self) -> bool
contains(&self, n: i32) -> bool
Depending on the concrete bit set implementation we could either have one of the following APIs:
storage::Bitset based on storage::Vec
push
pop
storage::Bitset based on storage::HashMap
insert
remove
We can also think about implementing both of the above versions.
The text was updated successfully, but these errors were encountered:
Commit ff1421c implements an initial version of a BitVec that is more similar to a vector than to a set of bits. However, this is the first step taken and could also potentially be used for many use bases.
Storage Bitset
The
pdsl_core
is currently missing an efficient and elegant way to handle bit sets.Using a
storage::Vec<bool>
is very inefficient, since it would require storing every single bit in a different storage cell and usingstorage::Vec<[u8; 32]>
(or similar) would require implementation effort from the user.The
storage::Bitset
should provide the most basic functionality for sets of bits and should be very efficient in the way that it reduces contract storage access to a minimum while keeping up with overall performance.Bits stored in the
storage::Bitset
should be bundled - for example as[u8; 32]
. This allows efficient contract storage access and lots of cache efficiency on the memory side.A
storage::Bitset
should allow iteration and the following APIs:symmetric_difference(&mut self, other: &Bitset)
*difference(&mut self, other: &Bitset)
*union(&mut self, other: &Bitset)
*intersection(&mut self, other: &Bitset)
*(*) Means that this API is not final.
is_disjoint(&self, other: &Bitset) -> bool
is_subset(&self, other: &Bitset) -> bool
is_superset(&self, other: &Bitset) -> bool
len(&self) -> u32
is_empty(&self) -> bool
contains(&self, n: i32) -> bool
Depending on the concrete bit set implementation we could either have one of the following APIs:
storage::Bitset
based onstorage::Vec
push
pop
storage::Bitset
based onstorage::HashMap
insert
remove
We can also think about implementing both of the above versions.
The text was updated successfully, but these errors were encountered: