summaryrefslogtreecommitdiff
path: root/AK/HashMap.h
AgeCommit message (Collapse)Author
2021-05-08AK: Add a non-const overload to HapMap::get()Itamar
Additionally, the const version of get() returns Optional<ConstPeekType> for smart pointers. For example, if the value in the HashMap is OwnPtr<u32>, HashMap::get() const returns Optional<const u32*>.
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-04-11AK: Annotate HashMap functions with [[nodiscard]]Brian Gianforcaro
2021-02-08Everywhere: Remove unnecessary headers 4/4Ben Wiederhake
Arbitrarily split up to make git bisect easier. These unnecessary #include's were found by combining an automated tool (which determined likely candidates) and some brain power (which decided whether the #include is also semantically superfluous).
2021-01-12AK: Simplify constructors and conversions from nullptr_tLenny Maiorani
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
2020-12-29AK: Add HashMap(std::initializer_list<Entry>) constructorLinus Groh
This allows us to construct a HashMap from an initializer list like so: HashMap<K, V> hash_map = { { K, V }, { K, V } { K, V } };
2020-11-12AK: Prefer using instead of typedefLenny Maiorani
Problem: - `typedef` is a keyword which comes from C and carries with it old syntax that is hard to read. - Creating type aliases with the `using` keyword allows for easier future maintenance because it supports template syntax. - There is inconsistent use of `typedef` vs `using`. Solution: - Use `clang-tidy`'s checker called `modernize-use-using` to update the syntax to use the newer syntax. - Remove unused functions to make `clang-tidy` happy. - This results in consistency within the codebase.
2020-09-25Meta+AK: Make clang-format-10 cleanBen Wiederhake
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-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: Add HashMap::find() with customizable finder callbackAndreas Kling
This will allow clients to search the map without having to instantiate a key value.
2019-08-14AK: Make it possible to use HashMap<K, NonnullOwnPtr>::get()Andreas Kling
Add the concept of a PeekType to Traits<T>. This is the type we'll return (wrapped in an Optional) from HashMap::get(). The PeekType for OwnPtr<T> and NonnullOwnPtr<T> is const T*, which means that HashMap::get() will return an Optional<const T*> for maps-of-those.
2019-07-24AK: Make HashMap::get(Key) return an Optional<Value>.Andreas Kling
This allows HashMap::get() to be used for value types that cannot be default constructed (e.g NonnullOwnPtr.)
2019-07-13AK: Support case-insensitive HashMap<String, T>.Andreas Kling
We achieve this by allowing you to specify custom traits for the key type. For convenience, we also provide a CaseInsensitiveStringTraits for String.
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-27AK: Simplify HashMap a bit.Andreas Kling
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-04-15LibCore: Add a CConfigFile class, a simple INI file parser.Andreas Kling
You open the configuration for an app like so: auto config = CConfigFile::get_for_app("MyApp"); This will then open ~/MyApp.ini and parse it for you. Immediately start using it in Minesweeper to load the field size and mine count from a config file.
2019-02-01Implement event loop timers.Andreas Kling
GObjects can now register a timer with the GEventLoop. This will eventually cause GTimerEvents to be dispatched to the GObject. This needed a few supporting changes in the kernel: - The PIT now ticks 1000 times/sec. - select() now supports an arbitrary timeout. - gettimeofday() now returns something in the tv_usec field. With these changes, the clock window in guitest2 finally ticks on its own.
2019-01-31Big, possibly complete sweep of naming changes.Andreas Kling
2018-12-31Make PageDirectory store physical pages in a HashMap.Andreas Kling
This container is really just there to keep a retain on the individual PhysicalPages for each page table. A HashMap does the job with far greater space efficiency.
2018-12-21Yet another pass of style fixes.Andreas Kling
2018-12-04Import a simple text editor I started working on.Andreas Kling
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-13Add HashMap::remove().Andreas Kling
2018-10-10Import all this stuff into a single repo called Serenity.Andreas Kling