generated from eng618/template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(list): standard library example
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |