Merge: lib/std/union_find: make DisjointSet Cloneable
authorJean Privat <jean@pryen.org>
Tue, 31 Mar 2015 03:22:05 +0000 (10:22 +0700)
committerJean Privat <jean@pryen.org>
Tue, 31 Mar 2015 03:22:05 +0000 (10:22 +0700)
commit2d0367d1c72c7de07b21daff6685044317d47f2b
tree7eeec17bf155309557b297259d256cd33ba2d6e3
parentbb979d4c4ad336340e67414ad5f0897e602ce211
parented999c6141a39712177763d1df4134c36ce6117e
Merge: lib/std/union_find: make DisjointSet Cloneable

Just because I need it.

I'm still not sure about what is the best way to deal with the various copy-constructors and clone methods. I think the following make sense:

A copy constructor named `from` that takes, if possible a general classifier (like an interface). This named constructor may use `nosuper` to avoid the automatic invocation of the standard init method if this cause a useless complex initialization that will be throw away by the copy.
A direct copy `clone` than can just return `new SELFTYPE.from(self)`

The advantage is that for simple clone, the `clone` method do the job.
If one want to change the class but keep the data, then the `from` constructor can be used. Like `new HashSet.from([1,2,3])`

Pull-Request: #1226
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>