Scala's collection library contains the forwarders IterableForwarder
, TraversableForwarder
, SeqForwarder
and proxies like IterableProxy
, MapProxy
, SeqProxy
, SetProxy
, TraversableProxy
, etc. Forwarders and proxies both delegate collection methods to an underlying collection object. The main difference between these two are that forwarders don't forward calls that would create new collection objects of the same kind.
In which cases would I prefer one of these types over the other? Why and when are forwarders useful? And if they are useful why are there no MapForwarder
and SetForwarder
?
I assume proxies are most often used if one wants to build a wrapper for a collection with additional methods or to pimp the standard collections.
ListBuffer
may answer the question why there are noMapForwarder
andSetForwarder
: because they are not required for implementingListBuffer
. – Byssus