various small documentation improvements (#18602)
This commit is contained in:
parent
a273ea70e8
commit
e616675c41
13 changed files with 123 additions and 97 deletions
|
|
@ -10,8 +10,9 @@
|
|||
## An implementation of a `deque`:idx: (double-ended queue).
|
||||
## The underlying implementation uses a `seq`.
|
||||
##
|
||||
## Note that none of the procs that get an individual value from the deque should be used
|
||||
## on an empty deque.
|
||||
## .. note:: None of the procs that get an individual value from the deque should be used
|
||||
## on an empty deque.
|
||||
##
|
||||
## If compiled with the `boundChecks` option, those procs will raise an `IndexDefect`
|
||||
## on such access. This should not be relied upon, as `-d:danger` or `--checks:off` will
|
||||
## disable those checks and then the procs may return garbage or crash the program.
|
||||
|
|
@ -198,7 +199,7 @@ iterator items*[T](deq: Deque[T]): lent T =
|
|||
## Yields every element of `deq`.
|
||||
##
|
||||
## **See also:**
|
||||
## * `mitems iterator <#mitems,Deque[T]>`_
|
||||
## * `mitems iterator <#mitems.i,Deque[T]>`_
|
||||
runnableExamples:
|
||||
from std/sequtils import toSeq
|
||||
|
||||
|
|
@ -214,7 +215,7 @@ iterator mitems*[T](deq: var Deque[T]): var T =
|
|||
## Yields every element of `deq`, which can be modified.
|
||||
##
|
||||
## **See also:**
|
||||
## * `items iterator <#items,Deque[T]>`_
|
||||
## * `items iterator <#items.i,Deque[T]>`_
|
||||
runnableExamples:
|
||||
var a = [10, 20, 30, 40, 50].toDeque
|
||||
assert $a == "[10, 20, 30, 40, 50]"
|
||||
|
|
@ -274,7 +275,7 @@ proc addFirst*[T](deq: var Deque[T], item: sink T) =
|
|||
## Adds an `item` to the beginning of `deq`.
|
||||
##
|
||||
## **See also:**
|
||||
## * `addLast proc <#addLast,Deque[T],T>`_
|
||||
## * `addLast proc <#addLast,Deque[T],sinkT>`_
|
||||
runnableExamples:
|
||||
var a = initDeque[int]()
|
||||
for i in 1 .. 5:
|
||||
|
|
@ -290,7 +291,7 @@ proc addLast*[T](deq: var Deque[T], item: sink T) =
|
|||
## Adds an `item` to the end of `deq`.
|
||||
##
|
||||
## **See also:**
|
||||
## * `addFirst proc <#addFirst,Deque[T],T>`_
|
||||
## * `addFirst proc <#addFirst,Deque[T],sinkT>`_
|
||||
runnableExamples:
|
||||
var a = initDeque[int]()
|
||||
for i in 1 .. 5:
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#
|
||||
|
||||
## Specialization of the generic `packedsets module <packedsets.html>`_
|
||||
## for ordinal sparse sets.
|
||||
## (see its documentation for more examples) for ordinal sparse sets.
|
||||
|
||||
import std/private/since
|
||||
import std/packedsets
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ template withLock(t, x: untyped) =
|
|||
release(t.lock)
|
||||
|
||||
proc iterAndMutate*[A](x: var SharedList[A]; action: proc(x: A): bool) =
|
||||
## Iterates over the list. If 'action' returns true, the
|
||||
## Iterates over the list. If `action` returns true, the
|
||||
## current item is removed from the list.
|
||||
##
|
||||
## .. warning:: It may not preserve the element order after some modifications.
|
||||
|
|
|
|||
|
|
@ -136,6 +136,8 @@ runnableExamples:
|
|||
## a more complex object as a key you will be greeted by a strange compiler
|
||||
## error:
|
||||
##
|
||||
## .. code::
|
||||
##
|
||||
## Error: type mismatch: got (Person)
|
||||
## but expected one of:
|
||||
## hashes.hash(x: openArray[A]): Hash
|
||||
|
|
@ -324,7 +326,7 @@ proc `[]`*[A, B](t: Table[A, B], key: A): B =
|
|||
## a default value (e.g. zero for int) if the key doesn't exist
|
||||
## * `getOrDefault proc<#getOrDefault,Table[A,B],A,B>`_ to return
|
||||
## a custom value if the key doesn't exist
|
||||
## * `[]= proc<#[]=,Table[A,B],A,B>`_ for inserting a new
|
||||
## * `[]= proc<#[]=,Table[A,B],A,sinkB>`_ for inserting a new
|
||||
## (key, value) pair in the table
|
||||
## * `hasKey proc<#hasKey,Table[A,B],A>`_ for checking if a key is in
|
||||
## the table
|
||||
|
|
@ -345,7 +347,7 @@ proc `[]`*[A, B](t: var Table[A, B], key: A): var B =
|
|||
## a default value (e.g. zero for int) if the key doesn't exist
|
||||
## * `getOrDefault proc<#getOrDefault,Table[A,B],A,B>`_ to return
|
||||
## a custom value if the key doesn't exist
|
||||
## * `[]= proc<#[]=,Table[A,B],A,B>`_ for inserting a new
|
||||
## * `[]= proc<#[]=,Table[A,B],A,sinkB>`_ for inserting a new
|
||||
## (key, value) pair in the table
|
||||
## * `hasKey proc<#hasKey,Table[A,B],A>`_ for checking if a key is in
|
||||
## the table
|
||||
|
|
@ -488,7 +490,7 @@ proc add*[A, B](t: var Table[A, B], key: A, val: sink B) {.deprecated:
|
|||
##
|
||||
## **This can introduce duplicate keys into the table!**
|
||||
##
|
||||
## Use `[]= proc<#[]=,Table[A,B],A,B>`_ for inserting a new
|
||||
## Use `[]= proc<#[]=,Table[A,B],A,sinkB>`_ for inserting a new
|
||||
## (key, value) pair in the table without introducing duplicates.
|
||||
addImpl(enlarge)
|
||||
|
||||
|
|
@ -499,7 +501,8 @@ template tabCellHash(i) = t.data[i].hcode
|
|||
proc del*[A, B](t: var Table[A, B], key: A) =
|
||||
## Deletes `key` from hash table `t`. Does nothing if the key does not exist.
|
||||
##
|
||||
## .. warning:: If duplicate keys were added, this may need to be called multiple times.
|
||||
## .. warning:: If duplicate keys were added (via the now deprecated `add` proc),
|
||||
## this may need to be called multiple times.
|
||||
##
|
||||
## See also:
|
||||
## * `pop proc<#pop,Table[A,B],A,B>`_
|
||||
|
|
@ -519,7 +522,8 @@ proc pop*[A, B](t: var Table[A, B], key: A, val: var B): bool =
|
|||
## mapping of the key. Otherwise, returns `false`, and the `val` is
|
||||
## unchanged.
|
||||
##
|
||||
## .. warning:: If duplicate keys were added, this may need to be called multiple times.
|
||||
## .. warning:: If duplicate keys were added (via the now deprecated `add` proc),
|
||||
## this may need to be called multiple times.
|
||||
##
|
||||
## See also:
|
||||
## * `del proc<#del,Table[A,B],A>`_
|
||||
|
|
@ -1028,7 +1032,8 @@ proc add*[A, B](t: TableRef[A, B], key: A, val: sink B) {.deprecated:
|
|||
proc del*[A, B](t: TableRef[A, B], key: A) =
|
||||
## Deletes `key` from hash table `t`. Does nothing if the key does not exist.
|
||||
##
|
||||
## **If duplicate keys were added, this may need to be called multiple times.**
|
||||
## .. warning:: If duplicate keys were added (via the now deprecated `add` proc),
|
||||
## this may need to be called multiple times.
|
||||
##
|
||||
## See also:
|
||||
## * `pop proc<#pop,TableRef[A,B],A,B>`_
|
||||
|
|
@ -1048,7 +1053,8 @@ proc pop*[A, B](t: TableRef[A, B], key: A, val: var B): bool =
|
|||
## mapping of the key. Otherwise, returns `false`, and the `val` is
|
||||
## unchanged.
|
||||
##
|
||||
## **If duplicate keys were added, this may need to be called multiple times.**
|
||||
## .. warning:: If duplicate keys were added (via the now deprecated `add` proc),
|
||||
## this may need to be called multiple times.
|
||||
##
|
||||
## See also:
|
||||
## * `del proc<#del,TableRef[A,B],A>`_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue