Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34056
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2016-04-02 07:10 -0700 |
| Message-ID | <feb2691d-116f-4519-9c4d-3e01294703aa@googlegroups.com> (permalink) |
| Subject | own stream reduction |
| From | Philipp Kraus <philipp.kraus.flashpixx@gmail.com> |
Hello,
I try to buld an own reduction stream reduction for my data structure.
I Have create an interface with:
interface Fuzzy<T>
{
T get();
double getWeight();
}
So I have build a class with: class FuzzyBoolean implements Fuzzy<Boolean>
I have got a list with IFuzzy<Boolean> objects and I would like to do something like
List<IFuzzy<Boolean>> mylist;
IFuzzy<Boolean> result = mylist.stream().reduce( myfuzzyreducing );
I'm searching for a tutorial or example how I can create an own reduce operator of my own type.
E.g. an reduction can be something like
Boolean b = true;
double w = 1;
for ( IFuzzy<Boolean> x : mylist )
{
b = b || x.get();
w = Math.min(w, x.getWeight());
}
new FuzzyBoolean( b, w );
or another
Boolean b = true;
double w = 0;
for ( IFuzzy<Boolean> x : mylist )
{
b = b || x.get();
w = w + x.getWeight()
}
new FuzzyBoolean( b, Math.max(1, w ) );
So I have got different reduction algorithms and would like to use this with the reduce( ) call.
How can I do this with an own streaming reduce structure?
Thanks
Phil
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
own stream reduction Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-04-02 07:10 -0700
Re: own stream reduction Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-04-02 10:23 -0400
Re: own stream reduction Sebastian <news@seyweiler.dyndns.org> - 2016-04-02 23:10 +0200
Re: own stream reduction Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-04-03 08:32 -0700
csiph-web