summary refs log tree commit diff stats
path: root/lib/pure/collections/tables.nim
Commit message (Collapse)AuthorAgeFilesLines
* fixes yet another strictdefs bug (#23069)ringabout2023-12-151-0/+3
|
* table.`mgetOrPut` without default val (#22994)inv20042023-11-301-0/+48
| | | | | | | | | | | 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 <>
* complete std prefixes for stdlib (#22887)ringabout2023-10-301-1/+1
| | | | 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
* Markdown code blocks migration part 8 (#22478)Andrey Makarov2023-08-151-15/+18
|
* use strictdefs for compiler (#22365)ringabout2023-08-061-4/+4
| | | | | | | | | | | | | | | * 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-231-2/+0
| | | fix #21251
* 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
|
* add `effectsOf` to `std/tables` (#20751)ringabout2022-11-041-2/+6
|
* remove `var` for ref parameters in `std/tables` (#20175)ringabout2022-08-251-2/+2
| | | remove `var` from ref parameters; make it consistent
* Deprecate `std/sharedlist` and `std/sharedtables` (#19112)konsumlamm2021-11-091-1/+0
|
* various small documentation improvements (#18602)Miran2021-07-281-7/+13
|
* 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>
* [std/tables] remove unnecessary `do: ` (#18160)flywind2021-06-021-10/+16
|
* Remove confusing <//> (#17830)flywind2021-04-261-7/+7
|
* CIs: attempt to use csources_v1 (#16282)Andreas Rumpf2021-04-211-1/+1
| | | | | | | | * CIs: attempt to use csources_v1 * also updated the BSDs * also updated azure pipelines * std modules should not itself use the 'std/' import dir... * compiler has to be careful with std/ for v1 booting
* lent support for tables (#17505)flywind2021-03-251-9/+9
|
* Use `.. warning::` (#17320)konsumlamm2021-03-101-2/+2
|
* Change stdlib imports to use std prefix in most examples (#17202)Danil Yarantsev2021-02-281-1/+1
|
* fix the wrong examples (#17035)flywind2021-02-151-19/+42
|
* tables module uses runnableExamples (#16994)flywind2021-02-131-333/+310
| | | | | * tables module use runnableExamples * disable the tests
* [ci skip] CountTable, remove link to unexisting procnarimiran2021-02-021-1/+0
|
* Fix broken links in docs (#16336)Elliot Waite2020-12-141-27/+27
| | | | | * Fix broken links in docs * Fix rand HSlice links
* move tests to testament (#16101)flywind2020-11-241-314/+0
| | | | | | | | | * move tests to testament * minor * fix random * disable test random
* Update tables documentation (#15807)Thomas Tay2020-11-021-0/+34
| | | | Added a case where a user might use mgetOrPut and create an accidental copy of a seq.
* fix #15750narimiran2020-10-281-0/+2
|
* Tables, use sink val arguments more actively (#15625)cooldome2020-10-191-9/+9
|
* Fix doc for CountTable (#15561) [backport]Christopher Dunn2020-10-131-1/+1
|
* remove annoying messages when creating orderedTables (#15309)flywind2020-09-121-11/+11
| | | | | * nativesockets docs minor [backport: 1.2] * remove annoying messages
* fixes #15021Araq2020-09-111-2/+2
|
* Add some enhancements to `jsonutils.nim` (#15133)Ivan Bobev2020-09-091-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add some enhancements to `jsonutils.nim` * Use `jsonutils.nim` hookable API to add a possibility to deserialize JSON arrays directly to `HashSet` and `OrderedSet` types and respectively to serialize those types to JSON arrays. * Also add a possibility to deserialize JSON `null` objects to Nim option objects and respectively to serialize Nim option object to JSON object if some or to JSON `null` object if none. * Move serialization/deserialization functionality for `Table` and `OrderedTable` types from `jsonutils.nim` to `tables.nim` via the hookable API. * Add object `jsonutils.Joptions` and parameter from its type to `jsonutils.fromJson` procedure to control whether to allow deserializing JSON objects to Nim objects when the JSON has some extra or missing keys. * Add unit tests for the added functionalities to `tjsonutils.nim`. * improve fromJsonFields * Add changelog entry for the jsonutils enhancements * Add TODO in `jsonutils.nim` * Added an entry to "Future directions" section in `jsonutils.nim` as suggestion for future support of serialization and de-serialization of nested variant objects. * Added currently disabled test case in `tjsonutils.nim` for testing serialization and de-serialization of nested variant objects. * Move JSON hooks to `jsonutils.nim` Move `fromJsonHook` and `toJsonHook` procedures for different types to `jsonutils.nim` module to avoid a dependency of collections modules to the `json.nim` module. The hooks are removed from the following modules: * `tables.nim` * `sets.nim` * `options.nim` * `strtabs.nim` * Add some tests about `StringTableRef` Add tests for `StringTableRef`'s `fromJsonHook` and `toJsonHook` to `tjsonutils.nim`. * Disable a warning in `jsonutils.nim` Mark `fun` template in `jsonutils` module with `{.used.}` pragma in order to disable `[XDeclaredButNotUsed]` hint. The template is actually used by the `initCaseObject` macro in the same module. Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
* fix in doc: incomplete output (#15222) [ci skip]Jon2020-08-241-1/+1
|
* Fix tables.CountTable largest and smallest (#15115)treeform2020-07-291-4/+4
| | | It needs to have len defined first because of the assert .len > 0. I just moved it up a bit to make them work.
* Fulfill https://github.com/nim-lang/Nim/pull/14995#issuecomment-664914391 ↵c-blake2020-07-281-33/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#15104) request. This can be conceived as an alternate, more capable resolution of https://github.com/nim-lang/Nim/issues/12200 than https://github.com/nim-lang/Nim/pull/12208 The code re-org idea here is to upgrade tablimpl.nim:`delImpl`/`delImplIdx` to abstract client code conventions for cell emptiness & cell hashing via three new template arguments - `makeEmpty`, `cellEmpty`, `cellHash` which all take a single integer argument and clear a cell, test if clear or produce the hash of the key stored at that index in `.data[]`. Then we update the 3 call sites (`Table`, `CountTable`, `SharedTable`) of `delImpl`/`delImplIdx` by defining define those arguments just before the first invocation as non-exported templates. Because `CountTable` does not save hash() outputs as `.hcode`, it needs a new tableimpl.nim:`delImplNoHCode` which simply in-lines the hash search when no `.hcode` field is available for "prefix compare" acceleration. It is conceivable this new template could be used by future variants, such as one optimized for integer keys where `hash()` and `==` are fast and `.hcode` is both wasted space & time (though a small change to interfaces there for a sentinel key meaning "empty" is needed for maximum efficiency). We also eliminate the old O(n) `proc remove(CountTable...)` in favor of simply invoking the new `delImpl*` templates and take care to correctly handle the case where `val` is either zero for non-existent keys in `inc` or evolves to zero over time in `[]=` or `inc`. The only user-visible changes from the +-42 delta here are speed, iteration order post deletes, and relaxing the `Positive` constraint on `val` in `proc inc` again, as indicated in the `changelog.md` entry.
* deprecate tables.allValues; continuation of #15047 (#15092)Miran2020-07-281-1/+2
|
* deprecate tables.add (#15047)Miran2020-07-251-4/+8
|
* remove a condition that table size must be passed as power of 2 (#14926)Miran2020-07-081-42/+6
| | | | | | | | | | | | | | | * remove a condition that table size must be passed as power of 2 * remove power-of-2 condition from sets and sharedtables * remove power-of-2 condition from deques * use 'correctSize' for both branches * prettify changelog.md and fix typos * add a changelog entry * fix double-call of 'right-size' * fix the same thing in sets.nim * introduce a new internal proc `slotsNeeded` Deprecate the public proc `rightSize`, which is not needed anymore. Now it is an identity function, allowing the old code to work correctly and without extra allocations.
* tables.nim: Add named fields in `smallest` and `largest` (#14919)ee72020-07-061-2/+2
| | | | | | | | | | The `smallest` and `largest` procs for `CountTable` returned a tuple with named fields, but the same procs for `CountTableRef` returned an anonymous tuple. This commit makes those `CountTableRef` procs more consistent, and adds a test. Fixes: #14918
* move since from inclrtl to std/private/since (#14188)hlaaftana2020-05-021-2/+2
| | | | * move since from inclrtl to std/private/since * move since import in system below for HCR
* Unwind just the "pseudorandom probing" part of recent sets,tables changes ↵c-blake2020-03-311-68/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#13816) * Unwind just the "pseudorandom probing" (whole hash-code-keyed variable stride double hashing) part of recent sets & tables changes (which has still been causing bugs over a month later (e.g., two days ago https://github.com/nim-lang/Nim/issues/13794) as well as still having several "figure this out" implementation question comments in them (see just diffs of this PR). This topic has been discussed in many places: https://github.com/nim-lang/Nim/issues/13393 https://github.com/nim-lang/Nim/pull/13418 https://github.com/nim-lang/Nim/pull/13440 https://github.com/nim-lang/Nim/issues/13794 Alternative/non-mandatory stronger integer hashes (or vice-versa opt-in identity hashes) are a better solution that is more general (no illusion of one hard-coded sequence solving all problems) while retaining the virtues of linear probing such as cache obliviousness and age-less tables under delete-heavy workloads (still untested after a month of this change). The only real solution for truly adversarial keys is a hash keyed off of data unobservable to attackers. That all fits better with a few families of user-pluggable/define-switchable hashes which can be provided in a separate PR more about `hashes.nim`. This PR carefully preserves the better (but still hard coded!) probing of the `intsets` and other recent fixes like `move` annotations, hash order invariant tests, `intsets.missingOrExcl` fixing, and the move of `rightSize` into `hashcommon.nim`. * Fix `data.len` -> `dataLen` problem.
* add `move` to `tables` to prevent warnings when compiled with `--gc:arc` ↵Miran2020-03-191-4/+4
| | | | (#13684)
* tables/sharedtables/intsets/etc: fix #13496, #13504, #13505; add lots of ↵Timothee Cour2020-02-261-5/+9
| | | | | | | | | | | tests (#13498) [backport] * fix #13496 handle tombstones * add test * more tests * fix #13504; add SharedTable tests * fix #https://github.com/nim-lang/Nim/issues/13505 intsets.missingOrExcl silently gave wrong results sometimes * add test for tintsets
* Remove testutils (#13435) [backport]Clyybber2020-02-191-3/+4
|
* [backport] pseudorandom probing for hash collision (#13418)Timothee Cour2020-02-191-47/+65
|
* remove outplace version of 'merge' for CountTables (#13377)Miran2020-02-101-19/+13
| | | | | | * remove outplace version of 'merge' for CountTables * remove 'merge' tests
* [backport] remove 'CountTable.mget' (#13355)Miran2020-02-071-13/+0
| | | It didn't work, and it was an oversight to be included in v1.0.
* [backport] fix #12813, fix #13079 (#13099)Miran2020-01-101-4/+14
| | | Correctly remove a key from CountTable when it is set to zero.