Merge pull request #4367 from kierdavis/4365-tables-clear
Improvements to tables.clear()
This commit is contained in:
commit
1e134aed49
4 changed files with 53 additions and 4 deletions
|
|
@ -118,7 +118,7 @@ template dataLen(t): untyped = len(t.data)
|
|||
|
||||
include tableimpl
|
||||
|
||||
proc clear*[A, B](t: Table[A, B] | TableRef[A, B]) =
|
||||
proc clear*[A, B](t: var Table[A, B] | TableRef[A, B]) =
|
||||
## Resets the table so that it is empty.
|
||||
clearImpl()
|
||||
|
||||
|
|
@ -457,7 +457,7 @@ proc len*[A, B](t: OrderedTable[A, B]): int {.inline.} =
|
|||
## returns the number of keys in `t`.
|
||||
result = t.counter
|
||||
|
||||
proc clear*[A, B](t: OrderedTable[A, B] | OrderedTableRef[A, B]) =
|
||||
proc clear*[A, B](t: var OrderedTable[A, B] | OrderedTableRef[A, B]) =
|
||||
## Resets the table so that it is empty.
|
||||
clearImpl()
|
||||
t.first = -1
|
||||
|
|
@ -786,7 +786,7 @@ proc len*[A](t: CountTable[A]): int =
|
|||
## returns the number of keys in `t`.
|
||||
result = t.counter
|
||||
|
||||
proc clear*[A](t: CountTable[A] | CountTableRef[A]) =
|
||||
proc clear*[A](t: var CountTable[A] | CountTableRef[A]) =
|
||||
## Resets the table so that it is empty.
|
||||
clearImpl()
|
||||
t.counter = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue