Skip to content

Commit 2788db4

Browse files
committed
docs: add doc comment for string
1 parent 74a6743 commit 2788db4

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/string.zig

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,18 @@ test "verify all" {
342342
}
343343
}
344344

345+
/// Given a `i32` slice `s` of length `n`, it returns the suffix array of `s`.
346+
/// Here, the suffix array `sa` of `s` is a permutation of $0, \cdots, n-1$ such that `s[sa[i]..n) < s[sa[i+1]..n)` holds for all $i = 0,1, \cdots ,n-2$.
347+
///
348+
/// # Constraints
349+
///
350+
/// - $0 \leq n \leq 10^8$
351+
/// - $0 \leq \mathrm{upper} \leq 10^8$
352+
/// - $0 \leq x \leq \mathrm{upper}$ for all elements $x$ of $s$.
353+
///
354+
/// # Complexity
355+
///
356+
/// - $O(n + \mathrm{upper})$-time
345357
pub fn suffixArrayManual(allocator: Allocator, s: []const i32, upper: i32) Allocator.Error![]usize {
346358
assert(upper >= 0);
347359
for (s) |elem| {
@@ -350,6 +362,17 @@ pub fn suffixArrayManual(allocator: Allocator, s: []const i32, upper: i32) Alloc
350362
return saIsI32(.default, allocator, s, upper);
351363
}
352364

365+
/// Given a `T` slice `s` of length `n`, it returns the suffix array of `s`.
366+
/// Here, the suffix array `sa` of `s` is a permutation of $0, \cdots, n-1$ such that `s[sa[i]..n) < s[sa[i+1]..n)` holds for all $i = 0,1, \cdots ,n-2$.
367+
///
368+
/// # Constraints
369+
///
370+
/// - $0 \leq n \leq 10^8$
371+
/// - `T` is integer type
372+
///
373+
/// # Complexity
374+
///
375+
/// - $O(n \log n)$-time, $O(n)$-space
353376
pub fn suffixArrayArbitrary(comptime T: type, allocator: Allocator, s: []const T) Allocator.Error![]usize {
354377
const n = s.len;
355378
var idx = try allocator.alloc(usize, n);
@@ -374,6 +397,16 @@ pub fn suffixArrayArbitrary(comptime T: type, allocator: Allocator, s: []const T
374397
return saIsI32(.default, allocator, s2, now);
375398
}
376399

400+
/// Given a string `s` of length `n`, it returns the suffix array of `s`.
401+
/// Here, the suffix array `sa` of `s` is a permutation of $0, \cdots, n-1$ such that `s[sa[i]..n) < s[sa[i+1]..n)` holds for all $i = 0,1, \cdots ,n-2$.
402+
///
403+
/// # Constraints
404+
///
405+
/// - $0 \leq n \leq 10^8$
406+
///
407+
/// # Complexity
408+
///
409+
/// - $O(n)$-time
377410
pub fn suffixArray(allocator: Allocator, s: []const u8) Allocator.Error![]usize {
378411
const n = s.len;
379412
const s2 = try allocator.alloc(usize, n);

0 commit comments

Comments
 (0)