Skip to content

Commit

Permalink
feat(list): standard library example
Browse files Browse the repository at this point in the history
  • Loading branch information
eng618 committed Dec 15, 2023
1 parent 67b6f03 commit 4ce6dfe
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ds/list/list_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package list_test

import (
"container/list"
"fmt"
)

// ExampleList is the provided example from the standard library container/list package.
// https://pkg.go.dev/container/list
func Example_standardLibraryList() {
// Create a new list and put some numbers in it.
l := list.New()
e4 := l.PushBack(4)
e1 := l.PushFront(1)
l.InsertBefore(3, e4)
l.InsertAfter(2, e1)

// Iterate through list and print its contents.
for e := l.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value)
}
}

0 comments on commit 4ce6dfe

Please sign in to comment.