package main
import (
"fmt"
)
func main() {
// Create an empty set using a map where the keys are of type string
set := make(map[string]struct{})
// Add elements to the set
set["apple"] = struct{}{}
set["banana"] = struct{}{}
set["orange"] = struct{}{}
// Check if an element exists in the set
if _, exists := set["banana"]; exists {
fmt.Println("Banana exists in the set")
}
// Remove an element from the set
delete(set, "orange")
// Display all elements in the set
fmt.Println("Elements in the set:")
for element := range set {
fmt.Println(element)
}
// Calculate the size of the set
fmt.Println("Size of the set:", len(set))
// Clear the set by creating a new empty map
set = make(map[string]struct{})
fmt.Println("Set cleared. Size:", len(set))
}