Skip to content

Commit

Permalink
examples
Browse files Browse the repository at this point in the history
  • Loading branch information
gaissmai committed Jan 30, 2023
1 parent cd91cc9 commit e2923f5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions example_period_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func (p uintInterval) String() string {
return fmt.Sprintf("%d...%d", p[0], p[1])
}

// The following example shows how to use the interval library with a simple interval and the correspondig
// compare function.
func ExampleNewTree() {
tree1 := interval.NewTree(cmpUintInterval, periods...)
tree1.Fprint(os.Stdout)
Expand All @@ -50,11 +52,12 @@ func ExampleNewTree() {
// └─ 7...9
}

// The Max funtion returns the interval with max left value.
func ExampleTree_Max() {
tree1 := interval.NewTree(cmpUintInterval, periods...)
tree1.Fprint(os.Stdout)

fmt.Println("\nInterval with max value in tree:")
fmt.Println("\nInterval with max left value in tree:")
fmt.Println(tree1.Max())
// Output:
// ▼
Expand All @@ -63,10 +66,11 @@ func ExampleTree_Max() {
// │ └─ 3...4
// └─ 7...9
//
//Interval with max value in tree:
//Interval with max left value in tree:
//7...9
}

// The following example explains the Covers method.
func ExampleTree_Covers() {
tree1 := interval.NewTree(cmpUintInterval, periods...)
tree1.Fprint(os.Stdout)
Expand All @@ -89,6 +93,7 @@ func ExampleTree_Covers() {
// 3...4
}

// The following example explains the CoveredBy method.
func ExampleTree_CoveredBy() {
tree1 := interval.NewTree(cmpUintInterval, periods...)
tree1.Fprint(os.Stdout)
Expand All @@ -111,6 +116,7 @@ func ExampleTree_CoveredBy() {
// 7...9
}

// The following example explains the Precedes method.
func ExampleTree_Precedes_period() {
tree1 := interval.NewTree(cmpUintInterval, periods...)
tree1.Fprint(os.Stdout)
Expand All @@ -132,6 +138,7 @@ func ExampleTree_Precedes_period() {
// 3...4
}

// The following example explains the Visit method.
func ExampleTree_Visit() {
tree1 := interval.NewTree(cmpUintInterval, periods...)
fmt.Println("parent/child printing")
Expand Down

0 comments on commit e2923f5

Please sign in to comment.