Commit graph

62 commits

Author SHA1 Message Date
D-Berg
a98d2540ae std.mem: remove deprecated functions 2025-11-30 16:44:19 +01:00
dweiller
cdc9d65b0d std.priority_queue: add useful functions from ArrayList API
The `ensureTotalCapacityPrecise`, `clearRetainingCapacity` and
`clearAndFree` functions from the ArrayList API are also useful for a
PriorityQueue.
2025-02-01 19:02:39 +01:00
Jora Troosh
13070448f5
std: fix typos (#20560) 2024-07-09 14:25:42 -07:00
Alex Kladov
9f4f43cf7f std: align PriorityQueue and ArrayList API-wise
ArrayList uses `items` slice  to store len initialized items, while
PriorityQueue stores `capacity` potentially uninitialized items.

This is a surprising difference in the API that leads to bugs!

https://github.com/tigerbeetle/tigerbeetle/pull/1948
2024-05-20 12:04:20 -04:00
Ryan Liptak
16b3d1004e Remove redundant test name prefixes now that test names are fully qualified
Follow up to #19079, which made test names fully qualified.

This fixes tests that now-redundant information in their test names. For example here's a fully qualified test name before the changes in this commit:

"priority_queue.test.std.PriorityQueue: shrinkAndFree"

and the same test's name after the changes in this commit:

"priority_queue.test.shrinkAndFree"
2024-02-26 15:18:31 -08:00
mlugg
51595d6b75
lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
Jacob Young
8f69e977f1 x86_64: implement 128-bit builtins
* `@clz`
 * `@ctz`
 * `@popCount`
 * `@byteSwap`
 * `@bitReverse`
 * various encodings used by std
2023-10-23 22:42:18 -04:00
Jacob Young
27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadb.
2023-10-22 15:46:43 -04:00
Andrew Kelley
6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab, reversing
changes made to 5f92b070bf.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Jacob Young
32e85d44eb x86_64: disable failing tests, enable test-std testing 2023-10-21 10:55:41 -04:00
Alexander Heinrich
4e188dd66c Update docs of PriorityQueue.iterator() and PriorityDeque.iterator() 2023-10-12 04:48:22 +03:00
Validark
8b1976cab5 [priority_queue] Simplify sifting & fix edge case 2023-07-24 12:58:19 -07:00
Andrew Kelley
aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
Frechdachs
478544239e
std: Fix update() method in PriorityQueue and PriorityDequeue (#13908)
Previously the update() method would iterate over its capacity, which may contain uninitialized memory or already removed elements.
2022-12-13 14:55:41 -05:00
Andrew Kelley
d3d24874c9 std: remove deprecated API for the upcoming release
See #3811
2022-09-16 14:46:53 -04:00
VÖRÖSKŐI András
d925d19cfc PriorityQueue: use compareFn in update()
update() calls mem.indexOfScalar() which uses `==` for comparing items,
which fails when the operator is not supported.
As PirorityQueue needs a comparing function anyway we can use `.eq` results
to identify matching objects.

closes #9918
2022-07-22 19:25:38 +03:00
Andrew Kelley
c3ae909e93 Revert "AstGen: preserve inferred ptr result loc for breaks"
This reverts commit 8bf3e1f8d0, which
introduced miscompilations for peer expressions any time they needed
coercions to runtime types.

I opened #11957 as a proposal to accomplish the goal of the reverted
commit.

Closes #11898
2022-06-28 18:38:25 -07:00
Veikka Tuominen
6b36774adc std: disable failing tests, add zig2 build test-std to CI 2022-06-12 10:43:28 +03:00
Veikka Tuominen
413577c881 std: adjust for stage2 semantics 2022-06-07 21:27:07 +03:00
joachimschmidt557
7deae07101 std.PriorityQueue: fix missing siftUp in remove
When the replacement node is smaller than its parent, we need to sift
up instead of sifting down.
2022-05-26 14:50:24 -04:00
Eric Shrewsberry
497f8a6098 Fix bug in PriorityQueue::removeIndex()
Fix to call siftDown on the removed index instead of always on index 0.
Updated test to a test that fails before and passes now.

PriorityDequeue does not have this issue.
2022-04-14 02:54:41 -04:00
Arnavion
82e8930656 std.priority_queue: allow comparator to take a context parameter 2021-12-15 17:46:04 -08:00
Lee Cannon
85de022c56
allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
Andrew Kelley
902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07:00
Max Hollmann
53b87fa78a Move compareFn from init to type constructor in PriorityQueue and PriorityDequeue.
This change significantly improves performance for simple compare functions and modifies
the API to be more consistent with e.g. `HashMap`.
2021-10-17 17:47:43 -04:00
Ryan Liptak
2be3b1d2bf std.PriorityQueue: ensureUnusedCapacity and ensureTotalCapacity
Same as c8ae581fef, but for PriorityQueue.
2021-09-19 13:52:56 +02:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
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-24 12:25:09 -07:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Matthew Borkowski
40a47eae65 fix shrinkAndFree and remove shrinkRetainingCapacity in PriorityQueue and PriorityDequeue 2021-05-12 18:33:25 -04:00
Veikka Tuominen
fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
Andrew Kelley
d780848ae4
Merge pull request #7792 from zanderxyz/zanderxyz/priority-dequeue
std: Add Priority Dequeue
2021-04-02 10:52:23 -07:00
daurnimator
d4af35b3fe HashMap.put returns !void, not a !bool 2021-02-27 13:11:47 +02:00
Zander Khan
ce22c70586 Change compareFn to fn (a: T, b: T) std.math.Order 2021-01-18 19:02:11 +00:00
Zander Khan
5bfd9238de Remove resize. Adding uninitialized memory at the end of the items would break the heap property. 2021-01-17 14:43:38 +00:00
Zander Khan
9a09ebb1b9 Replace shrink with shrinkAndFree and shrinkRetainingCapacity 2021-01-17 14:41:20 +00:00
Zander Khan
e1ab425bce Fix slice length when updating 2021-01-16 18:43:13 +00:00
Zander Khan
c6986f29f9 Fix update might change an element no longer in the queue 2021-01-16 18:11:26 +00:00
Zander Khan
4d09803414 Fix edge cases in fromOwnedSlice 2021-01-16 18:06:44 +00:00
Zander Khan
94c47855ec Add missing import 2021-01-16 17:48:29 +00:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
Vexu
7e30e83900
small fixes and zig fmt 2020-12-09 13:54:26 +02:00
Bhargav Srinivasan
84406d98e4 removing redundant assert 2020-09-22 05:12:21 -07:00
Bhargav Srinivasan
778bb4b324 return not found error correctly 2020-09-22 03:50:28 -07:00
Bhargav Srinivasan
983830a4ae replace linearSearch with mem.indexOfScalar, return not found error, factor out siftUp from addUnchecked, use compareFn to decide siftUp/siftDown 2020-09-22 03:46:13 -07:00
Bhargav Srinivasan
a5140cc902 implemented efficient heapreplace 2020-09-22 02:12:35 -07:00
Bhargav Srinivasan
1345f87f4e items are not sorted, using linear search 2020-09-22 01:50:22 -07:00
Bhargav Srinivasan
69f0fc513a sorry, local compiler using different version of zig 2020-09-22 01:36:41 -07:00
Bhargav Srinivasan
f083ea88d8 using binary search function from std.sort 2020-09-22 01:05:33 -07:00
Bhargav Srinivasan
26de64be13 adding a function to update the priority of an element 2020-09-21 23:09:22 -07:00
Literally Void
78baa16da0 Fix issue #6303: iterating empty PriorityQueue crashes 2020-09-10 12:00:53 +03:00