Reference implementation of Set data type exposed as functions.

* Plus, refactorings between abstract collection classes and implementations.
* Also introduced inference of dynamic Set type based on collection size (empty or not) and element type.