]> mj.ucw.cz Git - libucw.git/commitdiff
Doc: Described prime.h.
authorPavel Charvat <pchar@ucw.cz>
Mon, 10 Nov 2008 13:12:46 +0000 (14:12 +0100)
committerPavel Charvat <pchar@ucw.cz>
Mon, 10 Nov 2008 13:12:46 +0000 (14:12 +0100)
ucw/doc/Makefile
ucw/doc/index.txt
ucw/doc/prime.txt [new file with mode: 0644]
ucw/prime.h

index e5a4c926385587fae2d44336d39e6ef3ec0f6bb8..253bd3d23026cac52bf9974edc84dc6dfea0d7b2 100644 (file)
@@ -2,7 +2,7 @@
 
 DIRS+=ucw/doc
 
-UCW_DOCS=fastbuf index config configure install basecode hash docsys conf mempool eltpool mainloop generic growbuf unaligned lists chartype unicode
+UCW_DOCS=fastbuf index config configure install basecode hash docsys conf mempool eltpool mainloop generic growbuf unaligned lists chartype unicode prime
 UCW_INDEX=$(o)/ucw/doc/def_index.html
 UCW_DOCS_HTML=$(addprefix $(o)/ucw/doc/,$(addsuffix .html,$(UCW_DOCS)))
 
index e254a9a647ea26e816363809f0c58a9eec6256bb..60e2b93e40ecc51ba32292aa60def42763ef24e0 100644 (file)
@@ -26,6 +26,7 @@ Modules
 - <<growbuf:,Growing buffers>>
 - <<chartype:,Single-byte characters>>
 - <<unicode:,Multi-byte characters>>
+- <<prime:,Prime numbers>>
 
 Other features
 --------------
@@ -40,8 +41,6 @@ Yet undocumented modules
   * `sorter/`
 - Binary search
   * `binsearch.h`
-- Primes
-  * `prime.h`
 - Heaps
   * `binheap.h`
   * `binheap-node.h`
diff --git a/ucw/doc/prime.txt b/ucw/doc/prime.txt
new file mode 100644 (file)
index 0000000..2666de9
--- /dev/null
@@ -0,0 +1,7 @@
+Prime numbers
+=============
+
+The library defines some simple functions to generate prime numbers.
+They are useful for example in hash tables.
+
+!!ucw/prime.h
index 9ca2a01ebce72d48c2cdf878c8dc5d2e46ef2f87..87d13f92ed4fe285ae3925a411bd90b0e609b83c 100644 (file)
 
 /* prime.c */
 
+/**
+ * Return a non-zero value iff @x is a prime number.
+ * The time complexity is `O(sqrt(x))`.
+ **/
 int isprime(uns x);
+
+/**
+ * Return some prime greater than @x. The function does not checks overflows, but it should
+ * be safe at least for @x lower than `1U << 31`.
+ * If the Cramer's conjecture is true, it should have complexity `O(sqrt(x) * log(x)^2)`.
+ **/
 uns nextprime(uns x);
 
 /* primetable.c */
 
+/**
+ * Quickly lookup a precomputed table to return a prime number greater than @x.
+ * Returns zero if there is no such prime (we guarantee the existance of at
+ * least one prime greater than `1U << 31` in the table).
+ **/
 uns next_table_prime(uns x);
+
+/**
+ * Quickly lookup a precomputed table to return a prime number smaller than @x.
+ * Returns zero if @x is smaller than `7`.
+ **/
 uns prev_table_prime(uns x);
 
 #endif // _UCW_PRIME_H