Last active
December 17, 2015 13:49
-
-
Save nicl/5620254 to your computer and use it in GitHub Desktop.
Scala Universal Set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UniversalSet[A] extends Set[A] { | |
def contains(key: A) = true | |
def iterator = throw new UnsupportedOperationException() | |
def +(elem: A) = this | |
def -(elem: A) = throw new UnsupportedOperationException() | |
override def toString: String = "UniversalSet" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a bare minimum implementation. There are likely several other methods/traits I need to implement to make this usable, for example isEmpty(). In fact, any of the mixed-in methods that rely on iterator will error.