1package mapset 2 3import ( 4 "fmt" 5) 6 7type YourType struct { 8 Name string 9} 10 11func ExampleIterator() { 12 set := NewSetFromSlice([]interface{}{ 13 &YourType{Name: "Alise"}, 14 &YourType{Name: "Bob"}, 15 &YourType{Name: "John"}, 16 &YourType{Name: "Nick"}, 17 }) 18 19 var found *YourType 20 it := set.Iterator() 21 22 for elem := range it.C { 23 if elem.(*YourType).Name == "John" { 24 found = elem.(*YourType) 25 it.Stop() 26 } 27 } 28 29 fmt.Printf("Found %+v\n", found) 30 31 // Output: Found &{Name:John} 32} 33