summary refs log tree commit diff stats
path: root/lib/pure/collections/tables.nim
diff options
context:
space:
mode:
authorGrzegorz Adam Hankiewicz <gradha@imap.cc>2013-03-17 00:23:09 +0100
committerGrzegorz Adam Hankiewicz <gradha@imap.cc>2013-03-17 12:19:40 +0100
commit1bd12e208baaf3fcc3764facced2bd48508ad968 (patch)
treed82955bfc8b29d1504d6998df22a1d6632747f5a /lib/pure/collections/tables.nim
parent29d0a774e985fa457da14e288f1e2dc634496c8b (diff)
downloadNim-1bd12e208baaf3fcc3764facced2bd48508ad968.tar.gz
Mentions nextPowerOfTwo proc for table initialization.
Diffstat (limited to 'lib/pure/collections/tables.nim')
-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)