aboutsummaryrefslogtreecommitdiff
path: root/lib/std/array_hash_map.zig
AgeCommit message (Collapse)Author
2022-09-16std: remove deprecated API for the upcoming releaseAndrew Kelley
See #3811
2022-05-06Sema: solve a false positive "depends on itself"Andrew Kelley
This improves the ABI alignment resolution code. This commit fully enables the MachO linker code in stage3. Note, however, that there are still miscompilations in stage3.
2022-04-20std: fix missing hash map safetyAndrew Kelley
There was a missing compile error for calling ensureUnusedCapacity without a Context in the case that the Context is non-void.
2022-04-19array hash map: fix getOrPutAdapted on Managed array hash mapRobin Voetter
2022-04-18Update doc comment of ArrayHashMap to include 4th arg in eql fnsRyan Liptak
4th argument was added in cf88cf2657d721c68055a284e8c498a18639f74c
2022-04-02std.ArrayHashMap: lazier verifyContext callsAndrew Kelley
Companion commit to b45c6c757cb4a16f5021c8bf057d14183036f14c. Related: #11367
2022-03-10std: add sort method to ArrayHashMap and MultiArrayListAndrew Kelley
This also adds `std.sort.sortContext` and `std.sort.insertionSortContext` which are more advanced methods that allow overriding the `swap` method. The former calls the latter for now because reworking the main sort implementation is a big task that can be done later without any changes to the API.
2022-01-31std: make ArrayHashMap eql function accept an additional paramAndrew Kelley
which is the index of the key that already exists in the hash map. This enables the use case of using `AutoArrayHashMap(void, void)` which may seem surprising at first, but is actually pretty handy! This commit includes a proof-of-concept of how I want to use it, with a new InternArena abstraction for stage2 that provides a compact way to store values (and types) in an "internment arena", thus making types stored exactly once (per arena), representable with a single u32 as a reference to a type within an InternArena, and comparable with a simple u32 integer comparison. If both types are in the same InternArena, you can check if they are equal by seeing if their index is the same. What's neat about `AutoArrayHashMap(void, void)` is that it allows us to look up the indexes by key, *without actually storing the keys*. Instead, keys are treated as ephemeral values that are constructed as needed. As a result, we have an extremely efficient encoding of types and values, represented only by three arrays, which has no pointers, and can therefore be serialized and deserialized by a single writev/readv call. The `map` field is denormalized data and can be computed from the other two fields. This is in contrast to our current Type/Value system which makes extensive use of pointers. The test at the bottom of InternArena.zig passes in this commit.
2022-01-24Revert "MultiArrayList: Fix error when struct is 0 sized"Andrew Kelley
This reverts commit 1f10cf4edf2b645e63dedc42f5d7475914bf2311. Re-opens #10618 I want to solve this a different way. `align(S)` where S is a 0-byte type should work in this context. This also caused issues such as https://github.com/Vexu/arocc/issues/221
2022-01-24MultiArrayList: Fix error when struct is 0 sizedriverbl
Also fixes error with ArrayHashMap when both key and value are 0 sized
2021-11-30allocgate: std Allocator interface refactorLee Cannon
2021-11-30std lib API deprecations for the upcoming 0.9.0 releaseAndrew Kelley
See #3811
2021-10-04migrate from `std.Target.current` to `@import("builtin").target`Andrew Kelley
closes #9388 closes #9321
2021-09-19Update all ensureCapacity calls to the relevant non-deprecated versionRyan Liptak
2021-08-31std.hash_map: add getKey methods (#9607)fn ⌃ ⌥
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-08-04libstd: add ArrayHashMap.popOrNull functionJakub Konka
which internally calls `ArrayHashMap.pop`, however, returns `?KV` instead and performs the bounds checking automatically. This function correponds to `ArrayList.popOrNull` and is meant to fill the gap for situations where we want the quick lookup offered by the hash map with elegant ability to iterate and pop of the container with automatic bound checking that plugs in well with a `while`-loop such as ```zig var map = std.ArrayHashMap(K, V).init(allocator); map.deinit(); while (map.popOrNull()) |entry| { // ... do something } assert(map.count() == 0); ```
2021-06-21std: ArrayHashMap remove unused parameterAndrew Kelley
2021-06-21fix code broken from previous commitJacob G-W
2021-06-10zig fmtAndrew Kelley
2021-06-03Breaking hash map changes for 0.8.0Martin Wickham
- hash/eql functions moved into a Context object - *Context functions pass an explicit context - *Adapted functions pass specialized keys and contexts - new getPtr() function returns a pointer to value - remove functions renamed to fetchRemove - new remove functions return bool - removeAssertDiscard deleted, use assert(remove(...)) instead - Keys and values are stored in separate arrays - Entry is now {*K, *V}, the new KV is {K, V} - BufSet/BufMap functions renamed to match other set/map types - fixed iterating-while-modifying bug in src/link/C.zig
2021-05-12Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * lib/std/os/linux.zig * lib/std/os/windows/bits.zig * src/Module.zig * src/Sema.zig * test/stage2/test.zig Mainly I wanted Jakub's new macOS code for respecting stack size, since we now depend on it for debug builds able to pass one of the test cases for recursive comptime function calls with `@setEvalBranchQuota`. The conflicts were all trivial.
2021-05-11fix AutoArrayHashMap's store_hash logicMatthew Borkowski
2021-05-08Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * doc/langref.html.in * lib/std/enums.zig * lib/std/fmt.zig * lib/std/hash/auto_hash.zig * lib/std/math.zig * lib/std/mem.zig * lib/std/meta.zig * test/behavior/alignof.zig * test/behavior/bitcast.zig * test/behavior/bugs/1421.zig * test/behavior/cast.zig * test/behavior/ptrcast.zig * test/behavior/type_info.zig * test/behavior/vector.zig Master branch added `try` to a bunch of testing function calls, and some lines also had changed how to refer to the native architecture and other `@import("builtin")` stuff.
2021-05-08std: update usage of std.testingVeikka Tuominen
2021-05-06std.ArrayHashMap: ensureUnusedCapacity and ensureTotalCapacityAndrew Kelley
Same as 22015c1b3bfcf816faf10ea0fc152c4686efb363, but for ArrayHashMap.
2021-04-22std: fix compile errors caught by stage2 AstGenAndrew Kelley
* `comptime const` is redundant * don't use `extern enum`; specify a tag type. `extern enum` is only when you need tags to alias. But aliasing tags is a smell. I will be making a proposal shortly to remove `extern enum` from the language. * there is no such thing as `packed enum`. * instead of `catch |_|`, omit the capture entirely. * unused function definition with missing parameter name * using `try` outside of a function or test
2021-04-15std: change `@import("builtin")` to `std.builtin`Andrew Kelley
2021-03-28array_hash_map: decrement entries slice len after popping from entries in ↵lithdew
pop() to prevent oob
2021-02-24zig fmt the std libAndrew Kelley
2021-01-16std.ArrayHashMap: add "AssertDiscard" function variantsAndrew Kelley
* Add `swapRemoveAssertDiscard` * Add `orderedRemoveAssertDiscard` * Deprecate `removeAssertDiscard`
2021-01-06std: Support equivalent ArrayList operations in ArrayHashMapAlex Cameron
2021-01-06std: Rename ArrayList shrink => shrinkAndFreeAlex Cameron
2020-12-31Year++Frank Denis
2020-11-02std: Re-enable ArrayHashMap test for mips targetsLemonBoy
2020-09-25std.ArrayHashMap: count and iterator are not deprecatedAndrew Kelley
These APIs allow one to write code that is agnostic of whether it is using an ArrayHashMap or a HashMap, which can be valuable. Specify intent precisely: if you only need the count of the items, it makes sense to have a function for that.
2020-09-02hash_map: rename to ArrayHashMap and add new HashMap implementationSahnvour