You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthew O'Haire <MO...@Trysoft.com> on 2001/03/21 06:35:36 UTC

Parallel iteration

Hi folks,

I have two ArrayLists that are guaranteed to have the same number of
elements.
I need to iterate them in parallel, in pseudocode:

  for (i = 0; i<list.size(); i++) {
    display(list1.get(i));
    display(list2.get(i));
  }

Ideally I'd have a single list with each item being an array/class
containing 2 elements, ie:

  for (i = 0; i<list.size(); i++) {
    display(list1.get(i).element(0));
    display(list1.get(i).element(1));
  }

but I'm not in a position to change the array lists being returned (other
than repacking
them in the Action).

Any suggestions?


Matthew O'Haire
Technical Manager 
email: mohaire@trysoft.com 

IT Project Services & Solutions 
· Development · Integration · Support · People · 
44 Benson Street, Toowong, Queensland, Australia. 4066 
ph: +61-7-3870 7070 
fx: +61-7-3870 3480 
www: http://www.trysoft.com/ 
e-mail: trysoft@trysoft.com 

Please Note:
This document (including attachments) is only intended for the addressee/s
and may contain privileged or confidential information. Unauthorised use,
copying or distribution of the document or any part of its contents, is
prohibited. If you receive this e-mail in error please notify us by return
e-mail or telephone. 
Any views expressed in this Communication are those of the individual
sender, except where the sender specifically states them to be the views of
Trysoft Corporation Limited. 
Except as required at law, Trysoft Corporation Limited does not represent,
warrant and/or guarantee that the integrity of this communication has been
maintained nor that the communication is free of errors, virus, interception
or interference.




Re: Parallel iteration

Posted by William Jaynes <wj...@mediaone.net>.
At the risk of sounding flip, so repack them in the Action. Define an object that can contain both
elements, and create an ArrayList of those objects, each object populated from the corresponding
element from each of the two arrays. Then put that collection in the request or session and use it
in the interate tag in the jsp.

----- Original Message -----
From: "Matthew O'Haire" <MO...@Trysoft.com>
To: "Struts-User Mailing List (E-mail)" <st...@jakarta.apache.org>
Sent: Wednesday, March 21, 2001 12:35 AM
Subject: Parallel iteration


Hi folks,

I have two ArrayLists that are guaranteed to have the same number of
elements.
I need to iterate them in parallel, in pseudocode:

  for (i = 0; i<list.size(); i++) {
    display(list1.get(i));
    display(list2.get(i));
  }

Ideally I'd have a single list with each item being an array/class
containing 2 elements, ie:

  for (i = 0; i<list.size(); i++) {
    display(list1.get(i).element(0));
    display(list1.get(i).element(1));
  }

but I'm not in a position to change the array lists being returned (other
than repacking
them in the Action).

Any suggestions?


Matthew O'Haire
Technical Manager
email: mohaire@trysoft.com

IT Project Services & Solutions
· Development · Integration · Support · People ·
44 Benson Street, Toowong, Queensland, Australia. 4066
ph: +61-7-3870 7070
fx: +61-7-3870 3480
www: http://www.trysoft.com/
e-mail: trysoft@trysoft.com

Please Note:
This document (including attachments) is only intended for the addressee/s
and may contain privileged or confidential information. Unauthorised use,
copying or distribution of the document or any part of its contents, is
prohibited. If you receive this e-mail in error please notify us by return
e-mail or telephone.
Any views expressed in this Communication are those of the individual
sender, except where the sender specifically states them to be the views of
Trysoft Corporation Limited.
Except as required at law, Trysoft Corporation Limited does not represent,
warrant and/or guarantee that the integrity of this communication has been
maintained nor that the communication is free of errors, virus, interception
or interference.