Set is an interface of possible methods on 'set'.
| 16 | |
| 17 | // Set is an interface of possible methods on 'set'. |
| 18 | type Set[T comparable] interface { |
| 19 | // Add: adds new element to the set |
| 20 | Add(item T) |
| 21 | // Delete: deletes the passed element from the set if present |
| 22 | Delete(item T) |
| 23 | // Len: gives the length of the set (total no. of elements in set) |
| 24 | Len() int |
| 25 | // GetItems: gives the array( []T ) of elements of the set. |
| 26 | GetItems() []T |
| 27 | // In: checks whether item is present in set or not. |
| 28 | In(item T) bool |
| 29 | // IsSubsetOf: checks whether set is subset of set2 or not. |
| 30 | IsSubsetOf(set2 Set[T]) bool |
| 31 | // IsProperSubsetOf: checks whether set is proper subset of set2 or not. |
| 32 | // ex: [1,2,3] proper subset of [1,2,3,4] -> true |
| 33 | IsProperSubsetOf(set2 Set[T]) bool |
| 34 | // IsSupersetOf: checks whether set is superset of set2 or not. |
| 35 | IsSupersetOf(set2 Set[T]) bool |
| 36 | // IsProperSupersetOf: checks whether set is proper superset of set2 or not. |
| 37 | // ex: [1,2,3,4] proper superset of [1,2,3] -> true |
| 38 | IsProperSupersetOf(set2 Set[T]) bool |
| 39 | // Union: gives new union set of both sets. |
| 40 | // ex: [1,2,3] union [3,4,5] -> [1,2,3,4,5] |
| 41 | Union(set2 Set[T]) Set[T] |
| 42 | // Intersection: gives new intersection set of both sets. |
| 43 | // ex: [1,2,3] Intersection [3,4,5] -> [3] |
| 44 | Intersection(set2 Set[T]) Set[T] |
| 45 | // Difference: gives new difference set of both sets. |
| 46 | // ex: [1,2,3] Difference [3,4,5] -> [1,2] |
| 47 | Difference(set2 Set[T]) Set[T] |
| 48 | // SymmetricDifference: gives new symmetric difference set of both sets. |
| 49 | // ex: [1,2,3] SymmetricDifference [3,4,5] -> [1,2,4,5] |
| 50 | SymmetricDifference(set2 Set[T]) Set[T] |
| 51 | } |
| 52 | |
| 53 | type set[T comparable] struct { |
| 54 | elements map[T]bool |
no outgoing calls
no test coverage detected