Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

[AA rework] implemetation of hashOf #663

Merged
merged 2 commits into from Nov 17, 2013

Conversation

IgorStepanov
Copy link
Contributor

This pull request is first stage of @dawgfoto associative array reworking strategy. This PR introduces hashOf function, which can compute hash value for different time (including in CTFE if possible). The next stage is implementing of new templated AssociativeArray struct without using TypeInfo.

Note: hash value, computed with hashOf not equal TypeInfo.getHash(...) hash value.


testNumberConvert!("0.0Fi");
testNumberConvert!("0.0i");
testNumberConvert!("0.0Li");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generated 4 random floats, can you add them to the unittest casted to float, double and real.

-0x9.0f7ee55df77618fp-13829
0x7.36e6e2640120d28p+8797
-0x1.05df6ce4702ccf8p+15835
0x9.54bb0d88806f714p-7088

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@MartinNowak
Copy link
Member

Thanks, look amazing.
Of course the floating point stuff is ridiculously complex.

@MartinNowak
Copy link
Member

The hashOf function should be made accessible through object or some other core module.

@safe nothrow // pure can only be inferred because Object.toHash isn't pure
size_t hashOf(T)(auto ref T val)
{
    import core.internal.hash : hashOf;
    return hashOf(val);
}

I'd also like to mark all core.internal modules with package: protection but that doesn't work because object isn't in the core package.

@IgorStepanov
Copy link
Contributor Author

The hashOf function should be made accessible through object or some other core module.

I think, there isn't reason to publish hashOf now. (BTW it conflits with rt.util.hash.hashOf).
It should be publised after creating new AA.

MartinNowak added a commit that referenced this pull request Nov 17, 2013
[AA rework] implemetation of hashOf
@MartinNowak MartinNowak merged commit df2dd51 into dlang:master Nov 17, 2013
@IgorStepanov
Copy link
Contributor Author

Thanks. The next stage is implementing new templated aa (as core.internal.aa). I hope, I'll do it during this week.

@MartinNowak
Copy link
Member

This can be fairly simple. In rt.util.container.HashTab I've used the lower N bits for indexing, a singly linked list for each bucket and a simple grow policy to regulate the load factor.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants