-
Notifications
You must be signed in to change notification settings - Fork 99
Invariants should be documented and tested #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There's also a file on development/contributing info that I think may have some. |
I think you mean https://github.com/haskell-unordered-containers/unordered-containers/blob/master/docs/developer-guide.md. No additional invariants there AFAICT. |
I have added these items to the issue description:
|
TODO: Strictness invariants (#235 is related.) |
#444 has added the basic tooling for invariant-checking. Most I'm pretty pleased with this progress, anyway! :) |
This is tracked in #449. |
Indeed. Sorry for the duplicate. |
Information about invariants is scattered over the code and old issues. It would be good to collect it in one place and add tests or assertions to check that the invariants are upheld.
So far I'm aware of the following actual or supposed invariants:
Empty
can appear at the top-level, but never in the tree:unordered-containers/Data/HashMap/Internal.hs
Lines 380 to 383 in f59bb26
The array in
Full
has size2^bitsPerSubkey
:unordered-containers/Data/HashMap/Internal.hs
Lines 206 to 207 in f59bb26
In
BitmapIndexed b ary
,popcount b == size ary
(Add more detailed data structure information #161 (comment))When a
BitmapIndexed
contains only one subtree, that subtree is either aFull
orBitmapIndexed
node, but neverEmpty
,Leaf
orCollision
.The size of the array in
Collision
is at least 2.The size of the array in
BitmapIndexed
is at least 1 and less than2^bitsPerSubkey
.No two keys in a
HashMap
are equal according to(==)
.The hashes in
Leaf
andCollision
are those of the keys they contain.No two
Hash
es in aHashMap
are the same (but in aCollision
multiple keys have the same hash).In
BitmapIndexed b ary
, how exactly do the bits inb
correspond to the elements ofary
?The text was updated successfully, but these errors were encountered: