summary refs log tree commit diff stats
path: root/lib/pure/collections
Commit message (Collapse)AuthorAgeFilesLines
* table.`mgetOrPut` without default val (#22994)inv20042023-11-302-4/+65
| | | | | | | | | | | RFC: https://github.com/nim-lang/RFCs/issues/539 - ~~mgetOrPutDefaultImpl template into `tableimpl.nim` to avoid macros~~ - mgetOrPut for `Table`, `TableRef`, `OrderedTable`, `OrderedTableRef` - `tests/stdlib/tmget.nim` tests update --------- Co-authored-by: inv2004 <>
* fixes #22898; fix #22883 differently (#22900)ringabout2023-11-053-0/+10
| | | | | | fixes #22898 In these cases, the tables/sets are clears or elements are deleted from them. It's reasonable to suppress warnings because the value is not accessed anymore, which means it's safe to ignore the warnings.
* fixes #22883; replace `default(typeof(` with `reset`; suppress `Unsaf… ↵ringabout2023-11-013-7/+7
| | | | | | | | | | | | | | | | | | | | | | | (#22895) fixes #22883 …eDefault` warnings avoid issues mentioned by https://forum.nim-lang.org namely, it allocated unnecessary stack objects in the loop ```c while (1) { tyObject_N__8DSNqSGSHBKOhI8CqSgAow T5_; nimZeroMem((void *)(&T5_), sizeof(tyObject_N__8DSNqSGSHBKOhI8CqSgAow)); eqsink___test4954_u450((&(*t_p0).data.p->data[i].Field1), T5_); } ``` It might be more efficient in some cases follow up https://github.com/nim-lang/Nim/pull/21821
* complete std prefixes for stdlib (#22887)ringabout2023-10-306-7/+7
| | | | follow up https://github.com/nim-lang/Nim/pull/22851 follow up https://github.com/nim-lang/Nim/pull/22873
* use lent for the return value of index accesses of tables (#22812)ringabout2023-10-111-2/+2
| | | ref https://forum.nim-lang.org/t/10525
* remove the O(n*n) `addUnique` one from std (#22799)ringabout2023-10-061-12/+0
| | | | It's not used in the compiler, besides, it doesn't seem to be a common operation. Follows the discussion on the Discord.
* fixes #22554; makes `newSeqWith` use `newSeqUninit` (#22771)ringabout2023-09-301-1/+6
| | | fixes #22554
* moves `addUnique` to `std/sequtils` (#22734)Juan M Gómez2023-09-211-0/+28
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* define toList procs after add for lists [backport] (#22573)metagn2023-08-281-22/+22
| | | fixes #22543
* Add `cursor` to lists iterator variables (#22531)Amjad Ben Hedhili2023-08-241-3/+3
| | | * followup #21507
* Markdown code blocks migration part 8 (#22478)Andrey Makarov2023-08-153-25/+32
|
* use strictdefs for compiler (#22365)ringabout2023-08-066-10/+13
| | | | | | | | | | | | | | | * wip; use strictdefs for compiler * checkpoint * complete the chores * more fixes * first phase cleanup * Update compiler/bitsets.nim * cleanup
* fix #20023 hash for generic tables (#20346)Bung2023-06-211-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | * fix #20023 hash for generic tables * use default computation * Update lib/pure/collections/tables.nim Co-authored-by: Dan Rose <dan@digilabs.io> * Update lib/pure/collections/tables.nim Co-authored-by: Dan Rose <dan@digilabs.io> * Update lib/pure/collections/tables.nim * Update lib/pure/collections/tables.nim * Update t20023.nim --------- Co-authored-by: Dan Rose <dan@digilabs.io> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fix #21251 Compiler SIGSEGV when using SharedTable (#21876)Bung2023-05-233-8/+7
| | | fix #21251
* Add `minmax` to comparisons (#21820)Matt Wilson2023-05-121-0/+9
| | | | | | | | | | | | | | * Add `minmax` to sequtils This adds a `minmax` proc to complement `min` and `max`; it computes both results in a single pass for efficiency. * Update lib/pure/collections/sequtils.nim * Add minmax note to changelog. --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Revert "Add `cursor` to lists iterator variables" (#21571)ringabout2023-03-281-3/+3
| | | | | Revert "Add `cursor` to lists iterator variables (#21527)" This reverts commit 3936071772d648f98c36e5aad16a341b86344e6c.
* Add `cursor` to lists iterator variables (#21527)Amjad Ben Hedhili2023-03-271-3/+3
| | | * followup #21507
* fixes #21538; expand len template parameter once in newSeqWith (#21543)Eric N. Vander Weele2023-03-201-3/+3
| | | | | | | `len` could contain side effects and may result in different values when substituted twice in the template expansion. Instead, capture the result of substituting `len` once. closes: #21538
* Add `cursor` annotations to lists iterator variables (#21507)Amjad Ben Hedhili2023-03-131-2/+2
| | | | | Add `cursor` annotations to iterator variables * See https://nim-lang.github.io/Nim/destructors.html#the-cursor-pragma
* fixes #21393 and misc style changes (#21419)Andreas Rumpf2023-02-241-11/+20
| | | | | | | | | * fixes #21393 and misc style changes * progress --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* fixes backticks in the documentation (#21340)ringabout2023-02-081-2/+2
|
* fixes #21278; `deques.shrink` off by one bug (#21284)ringabout2023-01-201-1/+1
| | | fixes #21278; deques.shrink off ny one bug
* remove legacy code (#21134)ringabout2022-12-261-3/+0
| | | | | * remove legacy code * fixes
* Document that system:pop() may raise IndexDefect (#21070)Xavier Noria2022-12-131-3/+3
| | | | | * Document system:pop() may raise IndexDefect * Add backticks to KeyError
* Remove deprecated rightSize (#21011)Juan Carlos2022-12-081-10/+0
| | | | | * Remove deprecated rightSize nop * Remove deprecated rightSize nop
* add effectsOf to map in the std/sets module (#20760)ringabout2022-11-051-1/+4
|
* add `effectsOf` to `std/tables` (#20751)ringabout2022-11-041-2/+6
|
* removes channels_builtin when enabling `nimPreviewSlimSystem` (#20713)ringabout2022-10-311-1/+0
|
* out parameters: enforce that 'out' is only used as a parameter (#20510)Andreas Rumpf2022-10-072-2/+3
| | | | | | | * out parameters: enforce that 'out' is only used as a parameter * make tables.nim use 'out' parameters * better backwards compat
* new move analyser2 (#20471)Andreas Rumpf2022-10-011-2/+1
| | | | | | | | * produce better code for closure environment creation * new 'first write' analysis; * scope based move analyser * code cleanup Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* make more standard libraries work with `nimPreviewSlimSystem` (#20343)ringabout2022-09-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | * make more standard libraries work with `nimPreviewSlimSystem` * typo * part two * Delete specutils.nim * fixes more tests * more fixes * fixes tests * fixes three more tests * add formatfloat import * fix * last
* remove `var` for ref parameters in `std/tables` (#20175)ringabout2022-08-251-2/+2
| | | remove `var` from ref parameters; make it consistent
* top-down type inference, implements rfc 149 (#20091)metagn2022-08-241-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * micro implementation of rfc 149 refs https://github.com/nim-lang/RFCs/issues/149 * number/array/seq literals, more statements * try fix number literal alias issue * renew expectedType with if/case/try branch types * fix (nerf) index type handling and float typed int * use typeAllowed * tweaks + const test (tested locally) [skip ci] * fill out more of the checklist * more literals, change @ order, type conversions Not copying the full call tree before the typedesc call check in `semIndirectOp` is also a small performance improvement. * disable self-conversion warning * revert type conversions (maybe separate op later) * deal with CI for now (seems unrelated), try enums * workaround CI different way * proper fix * again * see sizes * lol * overload selection, simplify int literal -> float * range, new @ solution, try use fitNode for nil * use new magic * try fix ranges, new magic, deal with #20193 * add documentation, support templates Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* bootstrap the compiler with nimPreviewSlimSystem (#20176)ringabout2022-08-091-0/+3
| | | | | * bootstrap the compiler with nimPreviewSlimSystem * threads
* Add sink and lent annotations to the critbits module (#20021)silent-observer2022-07-141-8/+8
| | | | | | | | | * Add sink and lent to critbits * Remove lent for pairs I guess lent doesn't work well inside tuples * Remove lent from template in critbits Apparently this also doesn't work, because some checks failed
* Fix typo in sequtils documentation (#19789)Anthony Dario2022-05-131-1/+1
| | | Found another small typo.
* Fix broken link in sets documentation. (#19769)Anthony Dario2022-05-061-1/+1
|
* move assertions out of system (#19599)flywind2022-03-232-0/+8
|
* Fix `remove` on last node of singly-linked list [backport:1.6] (#19353)gecko2022-01-101-0/+2
|
* Fix #19314 - fixing broken `DoublyLinkedList` after adding empty ↵rockcavera2022-01-031-6/+6
| | | | | | | `DoublyLinkedList` (#19315) [backport] * Update lists.nim * Update tlists.nim
* Fix #19297 - fixing broken list after adding empty list (#19299)rockcavera2021-12-301-5/+6
| | | | | | | | | * Update lists.nim * Update tlists.nim * removed check `if b.tail != nil` The tail of the list being null it is still possible to retrieve its end by going through all nodes from the head. So checking for null from `b.tail` is unnecessary. However, setting `a.tail = b.tail` only if `a.head != nil`, so you don't break a good list with an already broken one.
* move toDeque to after addLast (#19233) [backport:1.0]MichalMarsalek2021-12-101-14/+14
| | | Changes the order of procs definitions in order to avoid calling an undefined proc.
* Deprecate `std/sharedlist` and `std/sharedtables` (#19112)konsumlamm2021-11-094-2/+4
|
* sequtils: fix errors from `strictFuncs` use (#18998)ee72021-10-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Nim 1.4.x compiled the below code without error when using `--experimental:strictFuncs` import std/sequtils type Foo = ref object let foo1 = Foo() let foo2 = Foo() let foos = @[foo1, foo2] let fooTuples = @[(foo1, 1), (foo2, 2)] discard repeat(foo1, 3) discard zip(foos, foos) discard unzip(fooTuples) However, since 2020-12-09, devel Nim produced errors like /tmp/bar.nim(11, 15) template/generic instantiation of `repeat` from here /foo/nim/pure/collections/sequtils.nim(172, 6) Error: 'repeat' can have side effects an object reachable from 'x' is potentially mutated /foo/nim/pure/collections/sequtils.nim(183, 15) the mutation is here /foo/nim/pure/collections/sequtils.nim(183, 15) is the statement that connected the mutation to the parameter This commit reverts some `proc` to `func` changes so that code that: - calls `repeat`, `zip`, or `unzip` - and instantiates them with types containing `ref` can once again be compiled with `strictFuncs`. Otherwise, a user might be forced to drop or alter their `strictFuncs` use when upgrading from Nim 1.4.x, or when writing new code that uses these procedures (at least for now, with the current `strictFuncs` implementation). This commit also adds tests to assert that the remaining funcs in this module can be compiled with `strictFuncs` when used with types containing `ref`. The original batch of `proc` to `func` changes in `sequtils.nim` was in commit 6f57ebae349f, which was partially reverted in 38eb021f8158. See also: https://github.com/nim-lang/Nim/issues/16305
* [minor] fix docs (#18834)flywind2021-09-111-6/+4
|
* sequtils now support strict effect tracking (#18782)Andreas Rumpf2021-09-021-9/+14
|
* various small documentation improvements (#18602)Miran2021-07-284-15/+22
|
* optimize for the non-throwing case (#18587)Antonis Geralis2021-07-261-4/+7
|
* complement notes of two doc strings of tables module (#18527)IterableTrucks2021-07-211-0/+4
| | | | | | | | | | | | | | | * complement notes of two doc strings warning the deprecated procedure's side effect * Update lib/pure/collections/tables.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * Update lib/pure/collections/tables.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: BillyZee <billyzee@localhost.localdomain> Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
* Revert #17321 (#18521)konsumlamm2021-07-191-135/+135
| | | Use better names in example