package in_optrator import ( "fmt" "github.com/emirpasic/gods/sets/hashset" "testing" ) func TestInOperation(t *testing.T) { // New可以方不同类型的元素 h1 := hashset.New("whw", "naruto", "sasuke", 123, 666) fmt.Println("1个元素:", h1.Contains("whw")) // true fmt.Println("多个元素:", h1.Contains("whw", 123)) // true fmt.Println("多个元素:", h1.Contains("whw", 123, 555)) // false // 其他方法 fmt.Println(h1.Empty()) // false fmt.Println(h1.Size()) // 5 fmt.Println(h1.Values()) // [sasuke 123 666 whw naruto] fmt.Println(h1.String()) /* HashSet 666, whw, naruto, sasuke, 123 */ // 清空~ h1.Clear() fmt.Println(h1.Size()) // 0 }
~~~