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)))
- <<growbuf:,Growing buffers>>
- <<chartype:,Single-byte characters>>
- <<unicode:,Multi-byte characters>>
+- <<prime:,Prime numbers>>
Other features
--------------
* `sorter/`
- Binary search
* `binsearch.h`
-- Primes
- * `prime.h`
- Heaps
* `binheap.h`
* `binheap-node.h`
/* 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