Using a simple<br> class Request{ String id;... }<br>and an auxiliary<br> class IdCount {String id; int count; ... }<br>and some insertions<br> kSession.insert( new Request( "a" ) );<br> kSession.insert( new Request( "b" ) );<br>
kSession.insert( new Request( "c" ) );<br> kSession.insert( new Request( "b" ) );<br> kSession.insert( new Request( "c" ) );<br> kSession.insert( new Request( "c" ) );<br>
the rule below<br><br>rule countById<br>when<br> $list: List()<br> from accumulate( Request( $id: id ),<br> init( Map id2count = new HashMap() ),<br> action( IdCount ic = (IdCount)id2count.get( $id );<br>
if( ic == null ){<br> ic = new IdCount( $id, 1 );<br> } else {<br> ic.setCount( ic.getCount() + 1 );<br> }<br>
id2count.put( $id, ic ); )<br> reverse( IdCount ic = (IdCount)id2count.get( $id );<br> ic.setCount( ic.getCount() - 1 );<br> id2count.put( $id, ic ); )<br>
result( id2count.values() ) )<br><br> IdCount( $id: id, $count: count > 1 ) from $list<br>then<br> System.out.println( "Id " + $id + ": " + $count );<br>end<br><br>produces<br> Id c: 3<br>
Id b: 2<br><br>-W<br><br><br><br><div class="gmail_quote">On 7 July 2011 16:55, Andre <span dir="ltr"><<a href="mailto:morpheusandre@web.de">morpheusandre@web.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
it seems much clearer, thxxxx but im afraid that this was not the last<br>
question...<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/sliding-window-combination-tp3132340p3148448.html" target="_blank">http://drools.46999.n3.nabble.com/sliding-window-combination-tp3132340p3148448.html</a><br>
</font><div><div></div><div class="h5">Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>