summaryrefslogtreecommitdiff
path: root/AK/HashTable.h
AgeCommit message (Collapse)Author
2020-10-18AK: Reduce memory writes in HashTable destructorDano Perniš
2020-10-18AK: Implement HashTable assignment in terms of swapDano Perniš
2020-10-18AK: Provide swap() for HashTableDano Perniš
2020-10-16AK: Tune HashTable load factorAndreas Kling
Double the capacity when used+deleted buckets crosses 60% of capacity. This appears to be a sweet spot for performance based on some ad-hoc testing with test-js. :^)
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-08-16AK: HashTable add a constructor that allows preallocation of capacity + Use ↵Muhammad Zahalqa
in CppLexer. (#3147) 1. Add general utility to get array number of elements. 2. Add Needed API to AK::HashTable 3. Refactor CppLexer initialization
2020-07-09AK: HashTable/HashMap return whether action was performed for set/removeTom
This allows performing an action based on whether something was actually added or removed without having to look it up prior to calling set() or remove().
2020-02-27AK: Expose SinglyLinkedListIterator constructorWilliam McPherson
This commit replaces SinglyLinkedListIterator::universal_end() with an empty SinglyLinkedListIterator(). Piano needs this in order to initialize a member array of iterators without 84 lines of universal_end().
2020-02-24AK: Make HashTable and HashMap use size_t for size and capacityAndreas Kling
2020-02-16AK: Add HashMap, HashTable and Traits to Forward.hAndreas Kling
2020-02-10AK: Remove bitrotted Traits::dump() mechanismAndreas Kling
This was only used by HashTable::dump() which I used when doing the first HashTable implementation. Removing this allows us to also remove most includes of <AK/kstdio.h>.
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.
2019-08-25AK: Make HashTable.h compile inside the SDL2 portAndreas Kling
2019-08-04HashTable: Use the Bucket type in some places over SinglyLinkedList<T>Andreas Kling
This is just for consistency, and we might want to switch to another bucket type some day.
2019-07-31HashTable: Assert on iteration attempt over table during clear/rehashAndreas Kling
It doesn't seem sane to try to iterate over a HashTable while it's in the middle of being cleared. Since this might cause strange problems, this patch adds an assertion if an iterator is constructed during clear() or rehash() of a HashTable.
2019-06-29AK: Allow HashMap to be used with non-default-constructible values.Andreas Kling
Solve this by adding find() overloads to HashTable and SinglyLinkedList that take a templated functor for comparing the values. This allows HashMap to call HashTable::find() without having to create a temporary Entry for use as the table key. :^)
2019-06-29AK: Defer to Traits<T> for equality comparison in container templates.Andreas Kling
This is prep work for supporting HashMap with NonnullRefPtr<T> as values. It's currently not possible because many HashTable functions require being able to default-construct the value type.
2019-06-29HashTable: Don't use move assignment in set(const T&).Andreas Kling
2019-06-27AK: Use a SinglyLinkedList<T> as HashTable's bucket chain storage.Andreas Kling
We were using a DoublyLinkedList<T> simply because it supported remove(). This patch consolidates the SinglyLinkedList iterators and adds remove().
2019-06-27AK: Consolidate iterators for HashTable and DoublyLinkedList respectively.Andreas Kling
Get rid of the ConstIterator classes for these containers and use templated FooIterator<T, ...> and FooIterator<const T, ...> helpers. This makes the HashTable class a lot easier to read.
2019-06-24AK: Make it possible to move and copy HashMap and HashTable.Andreas Kling
Previously it was only possible to move them, but we should allow copying as well, since it's gonna be useful for many things.
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-05-27AK: Add ensure_capacity() for HashMap and HashTable.Andreas Kling
These functions make sure that the underlying table can accomodate at least 'capacity' entries before needing a rehash.
2019-05-06AK: Change HashTable and HashMap size/capacity to be ints.Andreas Kling
2019-03-25AK: HashMap::set() didn't save new values for existing keys.Andreas Kling
2019-03-24LibGUI+FileManager: Add a GIcon class to support multi-size icons.Andreas Kling
A GIcon can contain any number of bitmaps internally, and will give you the best fitting icon when you call bitmap_for_size().
2019-02-04AK: Fix leak in HashTable move assignment operator.Andreas Kling
2019-01-30Fix dumb bug in HashTable::clear().Andreas Kling
We forgot to clear the m_buckets pointer. This meant that multiple calls to clear() would cause trouble.
2019-01-19Coding style fixes in AK.Andreas Kling
2018-12-21Yet another pass of style fixes.Andreas Kling
2018-12-04Import a simple text editor I started working on.Andreas Kling
2018-11-07Add some basic setgroups(), getgroups() and initgroups().Andreas Kling
Also teach /bin/id to print the user's supplemental groups.
2018-10-26Implement /proc/PID/vm.Andreas Kling
Refactored SyntheticFileSystem to maintain an arbitrary directory structure. ProcFileSystem creates a directory entry in /proc for each new process.
2018-10-25Add a very naive block cache to the DiskBackedFileSystem.Andreas Kling
This would be a lot better as an LRU. Right now it's a 32-slot hash table with random eviction.
2018-10-17Integrate ext2 from VFS into Kernel.Andreas Kling
2018-10-14Fix HashTable::find() return iterator for items found in non-0 buckets.Andreas Kling
2018-10-13Add HashTable::remove() and fix a bug where ConstIterator would skip the first.Andreas Kling
2018-10-13Add a DoublyLinkedList template and start using it for HashTable.Andreas Kling
2018-10-10Import all this stuff into a single repo called Serenity.Andreas Kling