mersinvald / primitive-map-rs Goto Github PK
View Code? Open in Web Editor NEW[WIP] Blazing fast [Integer -> T: Clone] Map crate
License: MIT License
[WIP] Blazing fast [Integer -> T: Clone] Map crate
License: MIT License
Implementation of retain
is blocked by #10 because of type difference
Currently PrimitiveMap::iter_mut
returns Option<&mut (Key, Value)>
, that makes it possible to mutate
the Key
and break the invariant leading to failing lookups by a new value of the Key
.
Even anyone who is familiar with principals of HashMap
data structure won't try to do so, it should be restricted by the API by returning Option<(Key, &mut Value)>
from the iterator.
In the current iterators implementation, the native IntoIterator
s of used underlying data structures are used, so the solution might be in wrapping Bucket
s into new types and reimplementing the IntoIterator
trait for them with more strict mutation constrains.
BST
layered on a Vec
/SmallVec
structure with map interface should be the default for PrimitiveMap
buckets.
Fitstly, it will support immutable keys in iterators to solve the problems described in #10.
Secondly, it should improve performance, as both insertion and querying of entries if O(logn)
, compared to Vec
/SmallVec
's O(n)
as both operations require looking up the element with the equal key.
Move all benchmarking and test deps into dev deps, make conditional compilation annotations.
struct PrimitiveMap<
K: Key,
V: Value,
B: Bucket<K, V>, <=== this
BL: BucketList<K, V, Bucket = B>,
H: Hasher<K> = DefaultHasher<K>,
> {
buckets: BL,
_marker: PhantomData<(K, V, B, H)>,
}
Currently, both new
and with_capacity
methods are described in the BucketStoreNew
.
It is implemented by Vec
which can implement both, and by Array
which can't accept arbitrary capacity in runtime, so it panics at runtime.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.