aboutsummaryrefslogtreecommitdiff
path: root/std/array_list.zig
AgeCommit message (Collapse)Author
2019-05-03std: add std.ArrayList.orderedRemovedaurnimator
2019-03-15breaking changes to std.mem.Allocator interface APIAndrew Kelley
Before, allocator implementations had to provide `allocFn`, `reallocFn`, and `freeFn`. Now, they must provide only `reallocFn` and `shrinkFn`. Reallocating from a zero length slice is allocation, and shrinking to a zero length slice is freeing. When the new memory size is less than or equal to the previous allocation size, `reallocFn` now has the option to return `error.OutOfMemory` to indicate that the allocator would not be able to take advantage of the new size. For more details see #1306. This commit closes #1306. This commit paves the way to solving #2009. This commit also introduces a memory leak to all coroutines. There is an issue where a coroutine calls the function and it frees its own stack frame, but then the return value of `shrinkFn` is a slice, which is implemented as an sret struct. Writing to the return pointer causes invalid memory write. We could work around it by having a global helper function which has a void return type and calling that instead. But instead this hack will suffice until I rework coroutines to be non-allocating. Basically coroutines are not supported right now until they are reworked as in #1194.
2019-03-02rename std lib files to new conventionAndrew Kelley
2019-02-08std.debug.assert: remove special case for test buildsAndrew Kelley
Previously, std.debug.assert would `@panic` in test builds, if the assertion failed. Now, it's always `unreachable`. This makes release mode test builds more accurately test the actual code that will be run. However this requires tests to call `std.testing.expect` rather than `std.debug.assert` to make sure output is correct. Here is the explanation of when to use either one, copied from the assert doc comments: Inside a test block, it is best to use the `std.testing` module rather than assert, because assert may not detect a test failure in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert is the correct function to use. closes #1304
2018-12-20tests: re: 79db394;kristopher tate
ref: ziglang/zig#1832
2018-11-13New Zig formal grammar (#1685)Jimmi Holst Christensen
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-10-15Solve the return type ambiguity (#1628)Jimmi Holst Christensen
Changed container and initializer syntax * <container> { ... } -> <container> . { ... } * <exrp> { ... } -> <expr> . { ...}
2018-09-13remove `this`. add `@This()`.Andrew Kelley
closes #1283
2018-09-09Add capacity and appendAssumeCapacity to ArrayListBas van den Berg
2018-07-17Add swapRemoveOrError (#1254)Wink Saville
* Add swapRemoveOrError, this mirrors setOrError.
2018-07-17Give ArrayList tests consistent names (#1253)Wink Saville
The recent change that added swapRemove used std.ArrayList as the test name prefix. Change the other tests to use the same prefix for consistency and making it easier to use --test-filter.
2018-07-16remove std.ArrayList.removeOrError functionAndrew Kelley
2018-07-14std.ArrayList - rename remove to swapRemoveAndrew Kelley
2018-07-14Added `remove` to ArrayListtgschultz
2018-07-13Add a copyBackwards to fix the broken insert methods for ArrayList.Bas van den Berg
2018-07-13Improve ArrayList insert unit tests.Bas van den Berg
2018-06-17remove integer and float casting syntaxAndrew Kelley
* add `@intCast` * add `@floatCast` * add `@floatToInt` * add `@intToFloat` See #1061
2018-06-16don't automatically take pointer when passing by non-copying valueAndrew Kelley
this commit does not have all tests passing
2018-06-09breaking syntax change: ??x to x.? (#1095)Andrew Kelley
See #1023 This also renames Nullable/Maybe to Optional
2018-06-09clean up std.ArrayListAndrew Kelley
* add `std.debug.assertError` * `std.ArrayList` update everything to follow `self` convention * rename `std.ArrayList.set` to `std.ArrayList.setOrError` * add `std.ArrayList.set` which asserts Before 1.0.0 we might remove some of this API, because you can use `toSlice()` for everything, but it's ok to add these functions as an experiment before then.
2018-06-09add set function to arraylistArthur Elliott
so you can set a value without growing the underlying buffer, with range safety checks
2018-05-31use * for pointer type instead of &Andrew Kelley
See #770 To help automatically translate code, see the zig-fmt-pointer-reform-2 branch. This will convert all & into *. Due to the syntax ambiguity (which is why we are making this change), even address-of & will turn into *, so you'll have to manually fix thes instances. You will be guaranteed to get compile errors for them - expected 'type', found 'foo'
2018-05-30run zig fmt on the codebaseAndrew Kelley
2018-05-26run zig fmt on some of the codebaseAndrew Kelley
See #1003
2018-05-09Merge branch 'master' into pointer-reformAndrew Kelley
2018-05-04Made container methods that can be const, constJimmi Holst Christensen
2018-05-03Unified APIBraedon
2018-05-01behavior tests passing with new pointer deref syntaxAndrew Kelley
2018-02-08Merge remote-tracking branch 'origin/master' into error-setsAndrew Kelley
2018-02-08Add ArrayList functions (#755)Marc Tiehuis
at - Get the item at the n-th index. insert - Insert and item into the middle of the list, resizing and copying existing elements if needed. insertSlice - Insert a slice into the middle of the list, resizing and copying existing elements if needed.
2018-01-31*WIP* error sets converting std libAndrew Kelley
2018-01-25syntax: functions require return type. remove `->`Andrew Kelley
The purpose of this is: * Only one way to do things * Changing a function with void return type to return a possible error becomes a 1 character change, subtly encouraging people to use errors. See #632 Here are some imperfect sed commands for performing this update: remove arrow: ``` sed -i 's/\(\bfn\b.*\)-> /\1/g' $(find . -name "*.zig") ``` add void: ``` sed -i 's/\(\bfn\b.*\))\s*{/\1) void {/g' $(find ../ -name "*.zig") ``` Some cleanup may be necessary, but this should do the bulk of the work.
2018-01-09remove %% prefix operatorAndrew Kelley
See #632 closes #545 closes #510 this makes #651 higher priority
2018-01-07replace `%return` with `try`Andrew Kelley
See #632 better fits the convention of using keywords for control flow
2017-12-23move std/debug.zig to a subdirectoryAndrew Kelley
self hosted compiler parser tests do some fuzz testing
2017-12-22explicitly return from blocksAndrew Kelley
instead of last statement being expression value closes #629
2017-12-10rendering source code without recursionAndrew Kelley
2017-11-10add a std lib test for reading and writing filesAndrew Kelley
* fix fstat wrong on darwin * move std.debug.global_allocator to std.debug.global_allocator_state and make it private * add std.debug.global_allocator as a pointer (to upgrade your zig code remove the '&')
2017-10-31breaking change to std.io APIAndrew Kelley
* Merge io.InStream and io.OutStream into io.File * Introduce io.OutStream and io.InStream interfaces - io.File implements both of these * Move mem.IncrementingAllocator to heap.IncrementingAllocator Instead of: ``` %return std.io.stderr.printf("hello\n"); ``` now do: ``` std.debug.warn("hello\n"); ``` To print to stdout, see `io.getStdOut()`. * Rename std.ArrayList.resizeDown to std.ArrayList.shrink.
2017-10-11implement command line argument parsing for windowsAndrew Kelley
See #302
2017-09-09Add appendSlice function (#448)Marc Tiehuis
2017-05-19change slicing syntax from ... to ..Andrew Kelley
See #359
2017-05-04std: rename List to ArrayList and re-organize...Andrew Kelley
...the exports of std. closes #356