summaryrefslogtreecommitdiff
path: root/AK/HashFunctions.h
AgeCommit message (Collapse)Author
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-01-07AK: Use a full-period xorshift PRNG for double_hashSchlufi
The previous implementation had some pretty short cycles and two fixed points (1711463637 and 2389024350). If two keys hashed to one of these values insertions and lookups would loop forever. This version is based on a standard xorshift PRNG with period 2**32-1. The all-zero state is usually forbidden, so we insert it into the cycle at an arbitrary location.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-02-08Everywhere: Fix weird includesBen Wiederhake
2020-10-21HashFunctions: constexpr capabilityLenny Maiorani
Problem: - Hash functions can be `constexpr`, but are not. Solution: - Change `inline` keyword to `constexpr`. - Add `static_assert` tests to ensure the hash functions work in a `constexpr` context.
2020-10-15AK: Redesign HashTable to use closed hashingAndreas Kling
Instead of each hash bucket being a SinglyLinkedList, switch to using closed hashing (open addressing). Buckets are chained together via double hashing (hashing the hash until we find an unused bucket.) This greatly reduces malloc traffic, since each added element no longer allocates a new linked list node. Appears performance neutral on test-js. Can definitely be tuned and could use proper management of load factor, etc.
2020-09-25Meta+AK: Make clang-format-10 cleanBen Wiederhake
2020-03-08AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)Andreas Kling
Use this instead of uintptr_t throughout the codebase. This makes it possible to pass a FlatPtr to something that has u32 and u64 overloads.
2020-02-25AK: Provide a ptr_hash(const void*) overloadAndreas Kling
2020-02-25AK: Add ptr_hash to use int_hash or u64_hash depending on pointer sizejoshua stein
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-05AK: Add a u64 Trait typeShannon Booth
This allows u64s to be used in HashMaps.
2019-07-03AK: Rename the common integer typedefs to make it obvious what they are.Andreas Kling
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
2019-05-28Add clang-format fileRobin Burchell
Also run it across the whole tree to get everything using the One True Style. We don't yet run this in an automated fashion as it's a little slow, but there is a snippet to do so in makeall.sh.
2019-01-31Big, possibly complete sweep of naming changes.Andreas Kling
2018-10-27Better int hashing. This was going to bite me sooner or later.Andreas Kling