Equal determines if two sets are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevant for sets to be equal.
(other StringSet)
| 151 | // If they both are the same size and have the same items they are considered equal. |
| 152 | // Order of items is not relevant for sets to be equal. |
| 153 | func (set StringSet) Equal(other StringSet) bool { |
| 154 | if set.Cardinality() != other.Cardinality() { |
| 155 | return false |
| 156 | } |
| 157 | for elem := range set { |
| 158 | if !other.Contains(elem) { |
| 159 | return false |
| 160 | } |
| 161 | } |
| 162 | return true |
| 163 | } |
| 164 | |
| 165 | // Returns a clone of the set. |
| 166 | // Does NOT clone the underlying elements. |