aboutsummaryrefslogtreecommitdiff
path: root/lib/std/array_hash_map.zig
AgeCommit message (Collapse)Author
2023-11-22std: remove meta.traitAndrew Kelley
In general, I don't like the idea of std.meta.trait, and so I am providing some guidance by deleting the entire namespace from the standard library and compiler codebase. My main criticism is that it's overcomplicated machinery that bloats compile times and is ultimately unnecessary given the existence of Zig's strong type system and reference traces. Users who want this can create a third party package that provides this functionality. closes #18051
2023-11-19lib: correct unnecessary uses of 'var'mlugg
2023-11-04std.ArrayHashMap: add init functionAndrew Kelley
for when you have keys and values array
2023-10-26x86_64: fix behavior of `getValue`Jacob Young
Old behavior renamed to `getValueIfFree`.
2023-10-23x86_64: implement enough to pass unicode testsJacob Young
* implement vector comparison * implement reduce for bool vectors * fix `@memcpy` bug * enable passing std tests
2023-10-22Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""Jacob Young
This reverts commit 6f0198cadbe29294f2bf3153a27beebd64377566.
2023-10-22Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"Andrew Kelley
This reverts commit 0c99ba1eab63865592bb084feb271cd4e4b0357e, reversing changes made to 5f92b070bf284f1493b1b5d433dd3adde2f46727. This caused a CI failure when it landed in master branch due to a 128-bit `@byteSwap` in std.mem.
2023-10-21x86_64: disable failing tests, enable test-std testingJacob Young
2023-10-08std: add unstable sorting to array hash mapsAndrew Kelley
closes #17426
2023-09-24std.MultiArrayList: add test coverage for 0-bit structsAndrew Kelley
closes #10618 solved by #17172
2023-09-02std.ArrayHashMap.reIndex also recomputes hashes (#17054)Josh Wolfe
2023-07-18compiler: rework inferred error setsAndrew Kelley
* move inferred error sets into InternPool. - they are now represented by pointing directly at the corresponding function body value. * inferred error set working memory is now in Sema and expires after the Sema for the function corresponding to the inferred error set is finished having its body analyzed. * error sets use a InternPool.Index.Slice rather than an actual slice to avoid lifetime issues.
2023-07-16std: reword some commentsAndrew Kelley
2023-06-26Change capacity to take a non-pointer parameterJobat
I don't believe there's a requirement for this to take a pointer, as the underlying function doesn't.
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-16migration: std.math.{min, min3, max, max3} -> `@min` & `@max`r00ster91
2023-04-28update codebase to use `@memset` and `@memcpy`Andrew Kelley
2023-04-25change semantics of `@memcpy` and `@memset`Andrew Kelley
Now they use slices or array pointers with any element type instead of requiring byte pointers. This is a breaking enhancement to the language. The safety check for overlapping pointers will be implemented in a future commit. closes #14040
2023-04-22doc: fix minor grammar issues-k
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2023-02-03use build.zig.zon instead of build.zig.ini for the manifest fileAndrew Kelley
* improve error message when build manifest file is missing * update std.zig.Ast to support ZON * Compilation.AllErrors.Message: make the notes field a const slice * move build manifest parsing logic into src/Manifest.zig and add more checks, and make the checks integrate into the standard error reporting code so that reported errors look sexy closes #14290
2022-12-17std.builtin: rename Type.UnionField and Type.StructField's field_type to typer00ster91
2022-12-04std: add move() functions to hash mapsAndrew Kelley
2022-11-29std.mem.Allocator: allow shrink to failAndrew Kelley
closes #13535
2022-10-03std: fix memory leak in ArrayHashMap (#13001)GethDW
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.