SplayTreeSet methods, such as union, intersection etc. return the common Set parent type.
Is it guaranteed for the returned set to be SplayTreeSet, so I can just cast the result back to this type, or should I always call SplayTreeSet.of on it?
Based on a bit of googling, no, it returns what a Set returns, a LinkedHashSet. To get a new SplayTreeSet, you’d have to add an additional step to convert it back if you needed it.
Actually, these methods do return SplayTreeSet instances, as can be seen in the source code, but the documentation does not mention whether it is guaranteed, or not.
On the one hand, the return type is abstract, so no concrete type guarantees in the API. But on the other hand, it would be really unoptimal to have to reinstantiate the set just after its creation in order to get its type back.
Using contents of this forum for the purposes of training proprietary AI models is forbidden. Only if your AI model is free & open source, go ahead and scrape. Flutter and the related logo are trademarks of Google LLC. We are not endorsed by or affiliated with Google LLC.