How to build a cluster array dynamically from another cluster array?

I'm working on a problem where I seem to be getting lost in a sea of
possibilities, none of which strikes me as optimum. Here's what I need to do.
I've got an input array of clusters (ARR1). Each cluster contains the
following components: an integer (INT1), a ring variable (RING1), a boolean
(BOOL1) and a cluster which itself is simply a bunch of ring variables
(CLUST1) Now, I need to transform that into a set of clusters (CLUST3) each of
which contains an array of characters (CHARARY2), a copy of the ring variable
(RING2), a copy of the boolean variable (BOOL2) and a copy of the cluster
(CLUST2).
To build the CLUST3, I need to find all elements within ARR1 that have the
same unique combination of RING1 and BOOL1, and if BOOL1 is True, then RING1
in addition, build an array of all the INT1 values corresponding to each
unique combination above converted to character, and then bundle this array
plus the unique combination of the other variables into a new cluster. In
general I could have several such clusters.
So if I had the following array to start with:
Index INT1 RING1 BOOL1 CLUST1
0 3 1 F {Values1}
1 2 1 T {Values2}
2 4 0 F {Values1}
3 6 0 F {Values3}
4 1 2 T {Values2}
5 4 2 T {Values2}
6 3 0 T {Values3}
7 4 2 T {Values3}
I should end up with the following clusters:
CHARARY2 RING2 BOOL1 CLUST1
"3" 1 F Don't care
"2" 1 T {Values2}
"4","6" 0 F Don't care
"1","4" 2 T {Values2}
"3" 0 T {Values3}
"4" 2 T {Values3}
What methods would you suggest for accomplishing this easily and efficiently?
Alex Rast
[email protected]
[email protected]

Tedious but not conceptually difficult.
ARR1 goes into a for loop, auto indexed on the FOR loop. The for loop has a
shift register which will be used to build the output array. Nested within
the for loop is another for loop, which the shift register array goes into,
again auto indexed, along with the element that has been auto-indexed from
ARR1. This for loop has a shift register, initialised with a boolean "true".
The inner loop compares the current element of ARR1 with the output array
and if an element in the output array is already present which matches the
input by your criteria, then the boolean register is set false; otherwise it
is left alone.
After the nested FOR loop you have a case fed from the boolean shift
register; if the boolean is true, the new element is unique and should be
added to the array. If it is false then a previous element has been found
making the present one redundant, and the array should be passed through
without adding the element.
In the true case, you simply unbundle the original element into its
components and build the new element, using "build array".
Notes for if the above is easy for you;
1) if handling lots of data then pre-initialise the shift register of your
outer loop with the same number of elements as your input array. Use
"Replace Array Subset" instead of "Build Array" to insert the current
element into the pre-allocated memory rather than having to create a new
array and copy all the current data across, which is what "Build Array" is
doing. Use "Array Subset" at the end to obtain a new array containing just
the elements you've used, removing the unused ones at the end.
2) Again for large datasets- the use of a while loop instead of the inner
for loop is more efficient since you can halt the while loop as soon as a
duplicate is found. With the described approach you have to go through the
whole array even if the first element turns out to be a duplicate- much
wasted computer time.
Alex Rast wrote in message
news:[email protected]...
> I'm working on a problem where I seem to be getting lost in a sea of
> possibilities, none of which strikes me as optimum. Here's what I need to
do.
>
> I've got an input array of clusters (ARR1). Each cluster contains the
> following components: an integer (INT1), a ring variable (RING1), a
boolean
> (BOOL1) and a cluster which itself is simply a bunch of ring variables
> (CLUST1) Now, I need to transform that into a set of clusters (CLUST3)
each of
> which contains an array of characters (CHARARY2), a copy of the ring
variable
> (RING2), a copy of the boolean variable (BOOL2) and a copy of the cluster
> (CLUST2).
>
> To build the CLUST3, I need to find all elements within ARR1 that have the
> same unique combination of RING1 and BOOL1, and if BOOL1 is True, then
RING1
> in addition, build an array of all the INT1 values corresponding to each
> unique combination above converted to character, and then bundle this
array
> plus the unique combination of the other variables into a new cluster. In
> general I could have several such clusters.
>
> So if I had the following array to start with:
>
> Index INT1 RING1 BOOL1 CLUST1
> ---------------------------------------------------
> 0 3 1 F {Values1}
> 1 2 1 T {Values2}
> 2 4 0 F {Values1}
> 3 6 0 F {Values3}
> 4 1 2 T {Values2}
> 5 4 2 T {Values2}
> 6 3 0 T {Values3}
> 7 4 2 T {Values3}
>
> I should end up with the following clusters:
>
> CHARARY2 RING2 BOOL1 CLUST1
> -----------------------------------------------------
> "3" 1 F Don't care
> "2" 1 T {Values2}
> "4","6" 0 F Don't care
> "1","4" 2 T {Values2}
> "3" 0 T {Values3}
> "4" 2 T {Values3}
>
> What methods would you suggest for accomplishing this easily and
efficiently?
>
> Alex Rast
> [email protected]
> [email protected]

Similar Messages

  • How to get the byte[] size dynamically from the StreamMessage object

    Hi all,
    Using JMS, I am receiving the FDF file as StreamMessage from the queue and attaching it to the PDF file which is present in the local system.
    For that, I have written the code as follows:
    {color:#0000ff} Message msg = jmsTemplate.receive();
    if(msg !=null && msg instanceof StreamMessage)
    StreamMessage message = (StreamMessage) msg;{color}
    {color:#ff6600}//hardcoded the byte array size value
    {color}{color:#0000ff} byte[] bytes = new byte[{color:#ff0000}856{color}];
    System.out.println("read msg="+message.readBytes(bytes));{color}
    {color:#0000ff}PdfReader pdfreader = new PdfReader("D:\\Managing_Workflows_No_Comment.pdf");
    PdfStamper stamp = new PdfStamper(pdfreader, new FileOutputStream("D:\\12345.pdf"));
    FdfReader fdfreader = new FdfReader(bytes);
    stamp.addComments(fdfreader);
    {color} {color:#0000ff} stamp.close();
    {color}{color:#000000}The above code is working fine except with the hardcoded of {color:#ff0000}byte array{color}{color:#ff0000} size value{color} which is given in {color:#ff0000}RED{color} in color.
    Can anybody know, {color:#000000}*how to get the byte[] size dynamically from the StreamMessage*{color} object ?
    Any help would be highly beneficial for me !!!!
    Thanks and Regards,
    Ganesh Kumar{color}

    When you create your stream message you could add an property to your message, something like streamSize that would contain the number of bytes in your stream message. Then you could get this property from the message before declaring your array.
    Tom

  • How do I unlink my Apple ID from another persons I tunes account? I keep getting their security questions and one of my emails can't be used

    How do I unlink my Apple ID from another persons I tunes account? I keep getting their security questions and one of my emails can't be used. It keeps telling me I its linked to another account but it shouldn't anymore. Plus my security questions belong to the other person and it has no reset option

    depend on the version of itunes and if it's OS X or windows i suppose
    in itunes on ny computer in the upper right corner left of the search bar there is a circle with a black siloet  and my name beside it
    if I click on the v beside it I can a menu with logout as an option

  • How can I make an audiobook purchased from another source show up in iTunes as an audiobook and not as music?

    How can I make an audiobook purchased from another source show up in iTunes as an audiobook and not as music?
    They chapters are mp3 files. Changing the genre to "audiobook" or "audiobooks" does help.
    I am sure this question will come up a lot, since the book in question is "Harry Potter and the Deathly Hallows," purchased from Pottermore.com.

    The one thing I would add to the instructions above is that the "Media Kind" menu is on the "Option" pane in the "Get Info" Window. This procedure has allowed me not only to make imported audiobooks show up as audiobooks, but imported podcasts show up as podcasts.

  • My ipod touch has a huge collection of music that I don't want to lose or replace but my computer has now crashed beyond recovery. How can I access my itunes account from another computer or transfer my playlists to another computer from my ipod?

    My ipod touch has a huge collection of music that I don't want to lose or replace but my computer has now crashed beyond recovery. How can I access my itunes account from another computer or transfer my playlists to another computer from my ipod?

    You can transfer iTunes purchases to your "new" computer by
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    You can transfer other stuff by:
    Best iPod to PC
    How to transfer or sync files from iPod to PC - Windows mac iPhone iPod software reviews - Software Wiki

  • How can i transfer a parchase movie from another iPad to my iPad

    How can i transfer a parchase movie from another iPad to my iPad

    Open the iTunes app. Tap the Purchased tab. Tap Movies.

  • How do I remove my phone number from another iCloud account so that text messages cannot be seen on another phone?

    How do I remove my phone number from another iCloud account. The issue is another phone receiving my text messages because of a shared apple ID.

    You can't remove your phone number from iMessage on an iPhone.  To prevent another phone from receiving your messages, use different Apple IDs for iMessage.  One of you should go to Settings>Messages>Send & Receive, tap the ID, sign out, then sign back in with a different ID.  You can still share the same ID for other services such as iTunes if you want; they don't have to be the same as your iMessage ID.

  • How to embed and launch ipa file from another ipa package created using Air for iOS

    Hi Guys,
    Anybody out there knowing how to embed and launch ipa file from another ipa package created using Air for iOS ?
    I am having 1 ipa file created using Xcode, Now i need to include that file in my ipa Package which is created using Flash CS 5.5 and Air for iOS. Also i need to know how to open my 1st ipa file from AS3 ?
    Thanks,

    Hi Sir,
    Thanks for your reply.
    But in that case user need to download 2 applications right. I need user to download my parent application created using Flash and that package contain one more ipa created using Xcode, so from my parent app only user should able to open my 2nd app. Is there any way to do that?
    Ps:  I am not talking about in-app but 2 individual apps inside one package.

  • How to refresh components of one jsf from another jsf (partialTriggers)

    This thread begins here:
    How to refresh components of one jsf from another jsf (partialTriggers)
    My apologies for post in other forum and thanks Frank for reply.
    I found a solution before read your post. I'm newbie and I ignore the use of colons. So, for do the problem that I explain in my post I must to change this code:
    public backing_home () {
    content = new RichPanelGroupLayout();
    content.setRendered (true);
    String[] partialTriggers = {"menu:menuItem1", "menu:menuItem2", "menu:menuItem3", "menu:menuItem4"}; //All id's of menuItems of the menuBar in menu.jsp
    this.content.setPartialTriggers(partialTriggers);
    Note that now I don't pass the item ID only. I add "menu:" before the ID. This allows to acces to name container ('menu' is de ID of subview). And that's all. This works!!
    Anyway, I test your propuse Frank. Thank you!
    Westh

    Westh,
    Yes this code appears to be correct. Was that your question?
    --Ric                                                                                                                                                                                   

  • How do i transfer photos and contacts from another phone to iPhone

    Ive ordered the new 4s and currently have the Galaxy II.  how do i transfer photos and contacts from another phone to iPhone?

    You will have to do it via either a computer or online storage such as Dropbox. You cannot transfer data directly from phone to iPhone.

  • How can I rent or purchase movies from another country store?

    How can I rent or purchase movies from another country store?

    You need to be in that country and supply a payment method valid there.
    (83400)

  • How can I select to send an from another email account within the inserted gmail account?

    How can I select to send an from another email account within the inserted gmail account?

    The Apple Support Communities are an international user to user technical support forum. As a man from Mexico, Spanish is my native tongue. I do not speak English very well, however, I do write in English with the aid of the Mac OS X spelling and grammar checks. I also live in a culture perhaps very very different from your own. When offering advice in the ASC, my comments are not meant to be anything more than helpful and certainly not to be taken as insults.
    The MAS should use any credits first and then apply the remainder to a listed bank card.

  • How do I import an address book from another user on same iMac?

    How do I import an address book from another user on same iMac?

    David...
    Try here >   Share one Address Book among multiple users

  • How can i install ios 8 downloaded from another source through flash drive?

    how can i install ios 8 downloaded from another source through flash drive?

    You can not download from a flash drive.  You can do over the air, or you can connect your iPhone to your computer and download iOS 8.1 via iTunes.

  • [iPhone 2.x] How to set text of a label from another classfile?

    I've a iPhone application (tabbar application) with some UIViewControllers. Per UIViewController i've created another .xib file.
    In one of the .xib files, i've created an UIView with an UILabel and created an outlet called "lblStatus" and connected it to the UILabel. I did all with Interface Builder.
    When i execute the application everything works great.
    Now i want to change the text of UILabel (lblStatus) from another class other then the class i've defined the outlet.
    MainWindow.xib
    - UITabBarController
    - UITabBar
    - UIViewController (viewController)
    - UIViewController (redirect to photosView.xib)
    photosView.xib
    - UIView (photosView)
    - UILabel (lblStatus)
    As you can see i've the classfile viewController (.h/.m). In that file i've the method called "viewDidLoad". I'm trying to set the text of lblStatus (defined in the classfile photosView (.h/.h) from this method.
    I've tried a lot but nothing works till now, how can i fix this?
    Thanks

    I believe the best way would be to setup a weak reference to the object.
    Check out "Object Ownership and Disposal" in "Memory Management Programming Guide for Cocoa":
    http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt. pdf

Maybe you are looking for

  • Macbookpro: daisy-chaining hard drives

    I'm new to this site so please bear with me. I have recently bought a macbookpro 2.8ghz with a 500gb (5400rpm) hard drive and 4Gb ram. I work with Logic Pro 8 and use more samples than audio for making music. I am wondering what is the best setup for

  • Collab File Upload

    Leveraging the new Collab API, how would one handle the actual upload of a new document? I know how to upload a document if I were not in the portal, but how does the document get placed in the document repository? I have been reading the documentati

  • Macbook air and timecapsule - fan problems (processor?)

    it only happens on the back up to time capsule and then MBA goes into overdrive with the fan up around 6200 rpm, istat pro tells me that cpu use is ok, but activity monitor, has a kernel task using 25% processor power. Sometimes the MBA will just fre

  • Album covers didn't come out after iTunes transfer...

    Hello!  Bought a Lumia 920 a week ago, and am loving it. However, after I transferred my music library from iTunes, many of the album cover art did not come through. In some cases, the area where the cover should be is just a gray box. Many of the en

  • It sounds like my hard drive is "leaking" or popping, for lack of a better term.

    First of all, I got a Macbook Pro MD104LL/A 2 1/2 weeks ago and the trackpad started being defective to a point to where it was a pain to mess with. So I ended up swapping it out for another one earlier today. Now after researching a bit, my hard dri