Equals - checks whether given set is equal to current set or not.
(sset Set[T])
| 112 | |
| 113 | // Equals - checks whether given set is equal to current set or not. |
| 114 | func (set Set[T]) Equals(sset Set[T]) bool { |
| 115 | // If length of set is not equal to length of given set, the |
| 116 | // set is not equal to given set. |
| 117 | if len(set) != len(sset) { |
| 118 | return false |
| 119 | } |
| 120 | |
| 121 | // As both sets are equal in length, check each elements are equal. |
| 122 | for k := range set { |
| 123 | if _, ok := sset[k]; !ok { |
| 124 | return false |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | return true |
| 129 | } |
| 130 | |
| 131 | // Intersection - returns the intersection with given set as new set. |
| 132 | func (set Set[T]) Intersection(sset Set[T]) Set[T] { |
no outgoing calls