Skip to content

Commit

Permalink
README.md: improve example.
Browse files Browse the repository at this point in the history
  • Loading branch information
avdva committed Sep 7, 2024
1 parent 30c8122 commit 0e5df00
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,20 @@ pub fn descendFromEnd(self: *Self) Iterator

Example:
```zig
const std = @import("std");
const math = std.math;
const zigavl = @import("zigavl");
fn i64Cmp(a: i64, b: i64) math.Order {
return math.order(a, b);
}
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.detectLeaks();
// first, create an i64-->i64 tree
const TreeType = lib.TreeWithOptions(i64, i64, i64Cmp, .{ .countChildren = true });
const TreeType = zigavl.TreeWithOptions(i64, i64, i64Cmp, .{ .countChildren = true });
var t = TreeType.init(gpa.allocator());
defer t.deinit();
// add some elements
Expand Down

0 comments on commit 0e5df00

Please sign in to comment.