[Soot-list] Jedd Relation Iterator

Ondrej Lhotak olhotak at uwaterloo.ca
Tue Nov 28 16:42:17 EST 2006


On Sun, Nov 26, 2006 at 12:13:35PM -0500, Saswat Anand wrote:
> 
> Hi,
> 
> When next() is called on the iterator of a Jedd relation, it returns an
> array of Object. I notice that the same array is returned (with different
> contents) every time next() is called on the iterator. I did not expect
> this behavior and was storing the arrays in a data structure for future use,
> which obviously did not work since the content of the array changed with
> subsequent calls to next().
> 
> Is the above behavior intentional?

Yes, it's intentional. In most cases, the iterator is used in a loop
where only one instance of the array is needed. Because the iterator may
be used to iterate over large relations, the overhead of allocating and
garbage collecting the array for each tuple could be significant. In the
rare case when one needs to keep several tuples around, one can make a
copy of the array.

I've added a javadoc comment explaining this behaviour.

> Thanks,
> Saswat
> 
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> 


More information about the Soot-list mailing list