Hello.

Le mer. 18 mars 2020 à 17:57, Gilles Sadowski <gillese...@gmail.com> a écrit :
>
> Hi.
>
> 2020-03-18 15:10 UTC+01:00, chentao...@qq.com <chentao...@qq.com>:
> > Hi,
> >     I have created a PR to show my aim:
> > https://github.com/apache/commons-math/pull/126/files
>
> Am I correct that the implementations of "ClustersPointExtractor"
> modify the argument of the "extract" method?
> If so, that seems quite unsafe.  I would not expect this behaviour
> in a public API.

To be clearer (hopefully): I'd contrast this (incomplete/non-compilable
code):

public class Extractor {
    T extract(List<List<T>> list);
}

with something along those lines:

public class ClusterSet<T> {
    private Set<T> data;
    private List<List<T>> clusters;

    void remove(T e) {
        return data.remove(e);
    }

    public interface Visitor {
        T visit(List<List<T>> list);
    }
}

Key point is separation of concern (selection of element vs
removal of element).

Of course the devil is in the details (maintain consistency among
the fields of "ClusterSet", ensure that "Visitor" implementations
cannot modify the internal state, ...).

> Unless I missed some point, I'd ask again that the API be reviewed
> *before* implementing several features (such as those "extractors")
> on top of something that does not look right.

One perspective might be to try and come with a design for use in
multi-threaded applications (see e.g. package "o.a.c.m.ml.neuralnet").

Best regards,
Gilles

> >> [...]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to