summary refs log tree commit diff stats
path: root/lib/pure/collections
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-03-17 08:15:15 -0700
committerAraq <rumpf_a@web.de>2013-03-17 08:15:15 -0700
commitaf7e862a06204291a9cb39a9f6583bb721fe208c (patch)
tree88bdae325b8fca41634e5f0d72aa86028042ce61 /lib/pure/collections
parent70c9009444a18fb297f3485f41f7639f24b64b15 (diff)
parent1bd12e208baaf3fcc3764facced2bd48508ad968 (diff)
downloadNim-af7e862a06204291a9cb39a9f6583bb721fe208c.tar.gz
Merge pull request #365 from gradha/pr_adds_mention_of_nextPowerOfTwo_proc
Mentions nextPowerOfTwo proc for table initialization.
Diffstat (limited to 'lib/pure/collections')
-rw-r--r--lib/pure/collections/tables.nim21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
index 4290af08a..02d099c1f 100644
--- a/lib/pure/collections/tables.nim
+++ b/lib/pure/collections/tables.nim
@@ -159,8 +159,11 @@ proc del*[A, B](t: var TTable[A, B], key: A) =
     dec(t.counter)
 
 proc initTable*[A, B](initialSize=64): TTable[A, B] =
-  ## creates a new hash table that is empty. `initialSize` needs to be
-  ## a power of two.
+  ## creates a new hash table that is empty.
+  ##
+  ## `initialSize` needs to be a power of two. If you need to accept runtime
+  ## values for this you could use the ``nextPowerOfTwo`` proc from the
+  ## `math <math.html>`_ module.
   assert isPowerOfTwo(initialSize)
   result.counter = 0
   newSeq(result.data, initialSize)
@@ -290,8 +293,11 @@ proc add*[A, B](t: var TOrderedTable[A, B], key: A, val: B) =
   AddImpl()
 
 proc initOrderedTable*[A, B](initialSize=64): TOrderedTable[A, B] =
-  ## creates a new ordered hash table that is empty. `initialSize` needs to be
-  ## a power of two.
+  ## creates a new ordered hash table that is empty.
+  ##
+  ## `initialSize` needs to be a power of two. If you need to accept runtime
+  ## values for this you could use the ``nextPowerOfTwo`` proc from the
+  ## `math <math.html>`_ module.
   assert isPowerOfTwo(initialSize)
   result.counter = 0
   result.first = -1
@@ -437,8 +443,11 @@ proc `[]=`*[A](t: var TCountTable[A], key: A, val: int) =
   PutImpl()
 
 proc initCountTable*[A](initialSize=64): TCountTable[A] =
-  ## creates a new count table that is empty. `initialSize` needs to be
-  ## a power of two.
+  ## creates a new count table that is empty.
+  ##
+  ## `initialSize` needs to be a power of two. If you need to accept runtime
+  ## values for this you could use the ``nextPowerOfTwo`` proc from the
+  ## `math <math.html>`_ module.
   assert isPowerOfTwo(initialSize)
   result.counter = 0
   newSeq(result.data, initialSize)