[rules-users] rule with array
Mark Proctor
mproctor at codehaus.org
Thu Feb 16 11:06:48 EST 2012
On 15/02/2012 18:36, shawn wrote:
> yeah, I have thought about it. But if I use function, I have to write three
> for loops. like:
>
> /*function Boolean findSubject(Request request) {
>
> Pointer sPointer = request.getSubjectPath();
> Pointer aPointer = request.getAuthorTable();
> for( int i = 0; i< p.length; i++ ) {
> for( int j = 0; j< p[i].length; j++) {
> for( Iterator iter = aPointer.iterator(); iter.hasNext(); )
> // if..else
>
> }
> }
> }*/
I haven't tried it, but something like this might work from a pure rules
perpsective:
$i : Object() from sPointer[]
$j : Object() from $i // I think this will instance of, checking it's a
array and thus iterate over it
$p : Object( this == $j ) from aPointer
But as that is create a Rete evaluation tree, it won't be as efficient
as a simple for loop. But would make an interesting test.
Mark
>
> sPointer is a int[][]; aPointer is a ArrayList. I need to find which element
> in aPointer has the same value in sPointer.
>
> If I use function, I think it the efficiency is not so good. Do you have any
> other ideas?
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/rule-with-array-tp3747680p3747895.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
More information about the rules-users
mailing list