Merging Arrays and Grouping

Hi guys,
I am trying to write an algorithm to merge an array of objects to cut down its size. Easier to understand by example.
Lets say I have 3 numbers , 1, 2 and 3. And 3 elements. So I want to create all combination's of these numbers. Like :
1,1,1
1,1,2
1,1,3
1,2,1
1,2,2
1,2,3
1,3,1
etc..
Then lets say I only had removed some of the combinations and was left with :
1,1,1
1,1,2
1,1,3
1,2,1
1,2,2
1,3,1
1,3,2
1,3,3
I would want this shortened to :
1,1,=
1,2,1
1,2,2
1,3,=
(= meaning all possible numbers, in this case 1 2 and 3)
Also if I had :
1,1,1
1,1,2
1,1,3
1,2,1
1,2,2
1,2,3
1,3,1
1,3,2
1,3,3
2,1,1
This would be shortened to :
1,=,=
2,1,1
And if I had :
1,1,1
1,1,2
1,2,1
1,2,3
1,3,1
This would be shortened to :
1,=,1
1,1,2
1,2,3
I think you'll get the idea from that. There could be more that 3 elements. I have been trying to work this out but its doing my head in.
Would be grateful if anyone could give me and tips or point me in the right direction.
Thanks.
Edited by: joeJack on Mar 1, 2010 12:21 PM
Changed from asterisk to equals sign as asterisk was creating bold text.

Hi
My suggested Algorithm is: Take a LinkedHashSet and put all possible combinations of merged objects from the number of elements. From your example all possible combination is 1==,2==,3==,11=,12=,13=,21=,22=,23=,31=,32=,33=. with all values 0(zero). Keep in mind that most general combination will be kept first like,1== and most specific at last i.e 12=,13=...etc
Now scan the each element one by on from array and if first character is 1 of the element increase the count of 1== by 1, if second character is 2 i.e element of the form 12 then increase the count of 12= by 1..and so on till last -1 character of the element.So that way we calculate the frequency of each element in on go.
Now check the number of the count for each element. Say for 1== count is 5 and we know that for 1== count has to be 9 (from permutation possible value 3* 3=9). Similarly go and check each element count and those element count which match the possible permutation value criteria they will be replace by that combination.
if array sixe is >>> than no of character in one string than this algorith will run ~~ n time where n size of array.

Similar Messages

  • Comparing and grouping Array Values

    Hello, I am relatively new to LabVIEW. I am currently analysing areas of individual particles using particle analyses. I am then outputting the results into a 1D array and sorting the array in ascending order. The size of the array changes depending on the image being analysed. What I want to do is search the array and group values which are similar and within a tolerance of say +/- 0.2. The number of groups need to be able to change automatically depending on the image being analysed.  Is there an easy way of doing this task? Help would be greatly appreciated.  
    Rob

    Hi Mike,
    Thank you for your reply.
    How can I sort the values into the correct group? I have attached my code.
    Many Thanks
    Rob
    Attachments:
    labVIEW Pic.doc ‏84 KB

  • Possible to use arrays and merge?

    Is it possible to use the results of APEX_UTIL.STRING_TO_TABLE in a merge statement? For example:
    l_selected := APEX_UTIL.STRING_TO_TABLE(:P4_V_METHODS);<br>
    l_methods := APEX_UTIL.STRING_TO_TABLE(:P4_VERIFICATION_SEQ);<p>
    merge into verification_results vr<br>
         using l_methods on (<br>
         l_methods = vr.verification_seq<br>
    ) <br>
    WHEN MATCHED THEN ...<p>
    etc.<p>
    It's a bit of a convoluted task that may not be possible. I've got checkboxes that hold the reference values (method_seq) and a hidden item that returns a string of the primary keys of a rel table (verification_results.verification_seq) and I want to merge what was stored and any new/different things that were checked.
    Y'all are going to want an example on apex.oracle.com, aren't you...
    thanks!

    Short answer, no. Used a couple arrays and loops instead.

  • Merging labview and mathscript array question tia sal2

    Greetings,
    I really like mathscript functionality it’s just taking a
    while to learn how to merge labview and mathscript together.  I can get an XY graph out which plots the
    correct wave function (thanks to the forums help) the problem is going from 1-D
    Array of cluster 2 elements to 1-D of waveform Double so I can get a sound representation
    of the waveform. 
    Anyone have any suggestions.
    Tia sal2
    Attachments:
    mathscript formula to sound with waveform graph.vi ‏248 KB

    Sorry not sure what happened internet gremlins maybe...here's the vi and graphic image
    Second try Hopefully this will work
    Attachments:
    mathscript formula waveform graph.vi ‏1 KB
    image_of_mathscript_to_labview.jpg ‏108 KB

  • Using an array within an array, and exporting to CSV

    I am gathering data about an AD user, including group membership and I want to output that to a CSV. Easy enough right? Not so much :) I am successfully generating 2 arrays, one has user data and the 2nd has group membership, but it's not exporting properly
    to CSV. I've tried the -notypeinformation but it's still showing up.
    My code is below, followed by contents of CSV file in text format.
    cls
    #declare array to use
    $user_main = @()
    $arrGroups = @()
    $user = Get-ADUser -Filter {samaccountname -eq "MyUserName"} -Properties *
    $temp_user.Name = $user.Name
    $temp_user.SAMname = $user.SamAccountName
    $temp_user.lastpwchange = $user.PasswordLastSet
    $temp_user.lastlogon = $user.LastLogonDate
    #get group membership
    $groups = $user.memberof
    foreach ($group in $groups)
    $temp1 = $group.Split(",")
    $group_name = $temp1[0].Substring(3, $temp1[0].Length -3)
    #$arrGroups += New-Object -TypeName psobject -Property $temp
    $arrGroups += $group_name
    $user_main += New-Object -TypeName psobject -Property $temp_user
    #$user_main | select * | Format-Table
    #$arrGroups
    $new = $user_main + $arrGroups
    Export-Csv -InputObject $new -Path c:\test\test.txt -NoTypeInformation -Encoding "utf8"
    Write-Host ""
    Write-Host "Done"
    The resulting text file contains:
    "Count","Length","LongLength","Rank","SyncRoot","IsReadOnly","IsFixedSize","IsSynchronized"
    "45","45","45","1","System.Object[]","False","True","False"
    So I have 2 issues. One is the "export-csv -notype" isn't working quite right, not sure why. And secondly, you can see the System.Object[] entry, which I believe is my array of groups. I need that to display the names of the groups the user belongs
    to.
    Any help is greatly appreciated!

    Hi Robert,
    I’m writing to just check in to see if the suggestions were helpful. If you need further help,
    please feel free to reply this post directly so we will be notified to follow it up.
    If you have any feedback on our support, please click here.
    Best Regards
    Anna
    TechNet Community Support

  • New files and folders on a Linux client mounting a Windows 2012 Server for NFS share do not inherit Owner and Group when SetGID bit set

    Problem statement
    When I mount a Windows NFS service file share using UUUA and set the Owner and Group, and set the SetGID bit on the parent folder in a hierarchy. New Files and folders inside and underneath the parent folder do not inherit the Owner and Group permissions
    of the parent.
    I am given to understand from this Microsoft KnowledgeBase article (http://support.microsoft.com/kb/951716/en-gb) the problem is due to the Windows implmentation of NFS Services not supporting the Solaris SystemV or BSD grpid "Semantics"
    However the article says the same functionality can acheived by using ACE Inheritance in conjunction with changing the Registry setting for "KeepInheritance" to enable Inheritance propagation of the Permissions by the Windows NFS Services.
    1. The Precise location of the "KeepInheritance" DWORD key appears to have "moved" in  Windows Server 2012 from a Services path to a Software path, is this documented somewhere? And after enabling it, (or creating it in the previous
    location) the feature seems non-functional. Is there a method to file a Bug with Microsoft for this Feature?
    2. All of the references on demonstrating how to set an ACE to achieve the same result "currently" either lead to broken links on Microsoft technical websites, or are not explicit they are vague or circumreferential. There are no plain Examples.
    Can an Example be provided?
    3. Is UUUA compatible with the method of setting ACE to acheive this result, or must the Linux client mount be "Mapped" using an Authentication source. And could that be with the new Flat File passwd and group files in c:\windows\system32\drivers\etc
    and is there an Example available.
    Scenario:
    Windows Server 2012 Standard
    File Server (Role)
    +- Server for NFS (Role) << -- installed
    General --
    Folder path: F:\Shares\raid-6-array
    Remote path: fs4:/raid-6-array
    Protocol: NFS
    Authentication --
    No server authentication
    +- No server authentication (AUTH_SYS)
    ++- Enable unmapped user access
    +++- Allow unmapped user access by UID/GID
    Share Permissions --
    Name: linux_nfs_client.host.edu
    Permissions: Read/Write
    Root Access: Allowed
    Encoding: ANSI
    NTFS Permissions --
    Type: Allow
    Principal: BUILTIN\Administrators
    Access: Full Control
    Applies to: This folder only
    Type: Allow
    Principal: NT AUTHORITY\SYSTEM
    Access: Full Control
    Applies to: This folder only
    -- John Willis, Facebook: John-Willis, Skype: john.willis7416

    I'm making some "major" progress on this problem.
    1. Apparently the "semantics" issue to honor SGID or grpid in NFS on the server side or the client side has been debated for some time. It also existed as of 2009 between Solaris nfs server and Linux nfs clients. The Linux community defaulted to declaring
    it a "Server" side issue to avoid "Race" conditions between simultaneous access users and the local file system daemons. The client would have to "check" for the SGID and reformulate its CREATE request to specify the Secondary group it would have to "notice"
    by which time it could have changed on the server. SUN declined to fix it.. even though there were reports it did not behave the same between nfs3 vs nfs4 daemons.. which might be because nfs4 servers have local ACL or ACE entries to process.. and a new local/nfs
    "inheritance" scheme to worry about honoring.. that could place it in conflict with remote access.. and push the responsibility "outwards" to the nfs client.. introducing a race condition, necessitating "locking" semantics.
    This article covers that discovery and no resolution - http://thr3ads.net/zfs-discuss/2009/10/569334-CR6894234-improved-sgid-directory-compatibility-with-non-Solaris-NFS-clients
    2. A much Older Microsoft Knowledge Based article had explicit examples of using Windows ACEs and Inheritance to "mitigate" the issue.. basically the nfs client "cannot" update an ACE to make it "Inheritable" [-but-] a Windows side Admin or Windows User
    [-can-] update or promote an existing ACE to "Inheritable"
    Here are the pertinent statements -
    "In Windows Services for UNIX 2.3, you can use the KeepInheritance registry value to set inheritable ACEs and to make sure that these ACEs apply to newly created files and folders on NFS shares."
    "Note About the Permissions That Are Set by NFS Clients
    The KeepInheritance option only applies ACEs that have inheritance enabled. Any permissions that are set by an NFS client will
    only apply to that file or folder, so the resulting ACEs created by an NFS client will
    not have inheritance set."
    "So
    If you want a folder's permissions to be inherited to new subfolders and files, you must set its permissions from the Windows NFS server because the permissions that are set by NFS clients only apply to the folder itself."
    http://support.microsoft.com/default.aspx?scid=kb;en-us;321049
    3. I have set up a Windows 2008r2 NFS server and mounted it with a Redhat Enteprise Linux 5 release 10 x86_64 server [Oct 31, 2013] and so far this does appear to be the case.
    4. In order to mount and then switch user to a non-root user to create subdirectories and files, I had to mount the NFS share (after enabling Anonymous AUTH_SYS mapping) this is not a good thing, but it was because I have been using UUUA - Unmapped Unix
    User Access Mapping, which makes no attempt to "map" a Unix UID/GID set by the NFS client to a Windows User account.
    To verify the Inheritance of additional ACEs on new subdirectories and files created by a non-root Unix user, on the Windows NFS server I used the right click properties, security tab context menu, then Advanced to list all the ACEs and looked at the far
    Column reflecting if it applied to [This folder only, or This folder and Subdirectories, or This folder and subdirectories and files]
    5. All new Subdirectories and files createdby the non-root user had a [Non-Inheritance] ACE created for them.
    6. I turned a [Non-Inheritance] ACE into an [Inheritance] ACE by selecting it then clicking [Edit] and using the Drop down to select [This folder, subdirs and files] then I went back to the NFS client and created more subdirs and files. Then back to the
    Windows NFS server and checked the new subdirs and folders and they did Inherit the Windows NFS server ACE! - However the UID/GID of the subdirs and folders remained unchanged, they did not reflect the new "Effective" ownership or group membership.
    7. I "believe" because I was using UUUA and working "behind" the UID/GID presentation layer for the NFS client, it did not update that presentation layer. It might do that "if" I were using a Mapping mechanism and mapped UID/GID to Windows User SIDs and
    Group SIDs. Windows 2008r2 no longer has a "simple" Mapping server, it does not accept flat text files and requires a Schema extension to Active Directory just to MAP a windows account to a UID/GID.. a lot of overhead. Windows Server 2012 accepts flat text
    files like /etc/passwd and /etc/group to perform this function and is next on my list of things to see if that will update the UID/GID based on the Windows ACE entries. Since the Local ACE take precedence "over" Inherited ACEs there could be a problem. The
    Inheritance appears to be intended [only] to retain Administrative rights over user created subdirs and files by adding an additional ACE at the time of creation.
    8. I did verify from the NFS client side in Linux that "Even though" the UID/GID seem to reflect the local non-root user should not have the ability to traverse or create new files, the "phantom" NFS Server ACEs are in place and do permit the function..
    reconciling the "view" with "reality" appears problematic, unless the User Mapping will update "effective" rights and ownership in the "view"
    -- John Willis, Facebook: John-Willis, Skype: john.willis7416

  • Hei , i was window user an just switched to ipone 6 , can i merge my contacts group from windows to IOS ? please quide

    hei , i was window user an just switched to ipone 6 , can i merge my contacts group from windows to IOS ? please quide

    Right, I finally managed to get it sorted out.
    iCloud only accept version 3.0 vcards, and the one I was using were version 2.1 so that's why it wasn't picking it up. So the easy way to get that sorted out is, use a gmail account.
    I know you don't wanna do it because you think it's too much hassle and stuff, but trust me it only takes 5 minutes and that's it.
    1. Create a Gmail Account.
    2. Export your Old VCard files to the Gmail Account.
    3. Now Import them from Gmail to your PC again.
    And, that's it, that's just makes the new imported version in 1 file contains your all contacts in version 3.0. Now you can just upload that on icloud and then sync it with your iphone.
    That's what I did and it worked, and I am sure if you wanna replace this file in the Contacts folder under your User Account in Windows and then try to sync Contacts in Tunes, it should work, but as I said, I did it with iCloud and it worked for me. So aye, that's pretty much it. Phewwww..
    Been searching for it for the whole day and it took 5 minutes in the end, badass...
    Anyway, don't lose hope and always Google for everything!

  • Splitting and grouping of data from incoming string

    Hello,
    I have a package of data coming from the serial port and read out as a string.
    The package has the following format, to be short.
    1. opening characters
    2. 2 bytes for Group ID(identify the device# the data comes from).
    3. Sensors data belongs to device# (1 byte each)
    -data of sensor #1
    -data of sensor #2
    -data of sensor #3
    -data of sensor #4
    and loop back to sensor 1,2,3,4 for 20 bytes total.
    I have eliminated the opening characters with the replace substring with empty string. For the Group ID, I used a case structure to identify which device it is. For the sensor data, I need to split them up and group all the data of the sensors together. I tried using substring for each sensor in a for loop that loop 5 times to group the data of each sensor together but it only give me the very last values.
    My goal is to be able to extract and group the 5 bytes of each sensor together everytime the serial package comes in and then save them to a separte files for each sensor. I also want to be able to plot the data of each sensor as they come in with respect to time.
    Any idea on how I can accomplish the grouping of data described above? I really appreciate your prompt response. Thanks,

    Since you already know how to separate the sting containing the sensors data, you just have to use a string to byte function and to decimate the resulting array, as shown in the attached vi.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Sensor data.vi ‏39 KB

  • Unmarshaling fails after changing top level node from Array to Group

    Hi all,
    I created a custom OTD to read in the contents of a flat file. The top node was set to Array and it unmarshaled the data ok. Now one of my fellow developers changed my top node to a Group because in my otd there was not array delimiter set according to him. Now my unmarshaling fails with the following error:
    There was an error during unmarshal.
    <SOD>""<POS>"H14954510 ..." failed input match, after recordGroup[0]: left over 14290 bytes at end of data .
    Does this mean there is more data than what is expected to be received?
    When enabling Verbose Mode in my otd tester, the following out put is displayed:
    [ parse #0 ]
    [ parse 'otdInput', pos=0, end=14290, mandatory  ]
    [ parse group, count=0, order=0, must ]
    [ parse #1 ]
    [ parse 'recordGroup', pos=0, end=14290, mandatory  ]
    [ parse group, count=0, order=0, must ]
    [ parse #2 ]
    [ parse 'header', pos=0, end=14290 ]
    [ parse group delim, Fog#13 ]
    [ - push local delim list ]
    [ - iteration #0 ]
    [ parse 'rectype', pos=0, end=14290 ]
    [ parse fixed, Fog#14, count=0 ]
    [ - match BEGIN "H1" ]
    [ - matched data 0 to 2: "H1" ]
    [ - parse: result=1 ]
    [ - parse: 'rectype' , done=false, pos=2, end=14290, last=EOD ]
    [ parse 'PackListNumber', pos=2, end=14290 ]
    [ parse fixed, Fog#458, count=0 ]
    [ - matched data 2 to 22: "4954510             " ]
    [ - parse: result=1 ]
    [ - parse: 'PackListNumber' , done=false, pos=22, end=14290, last=EOD ]
    [ parse 'SequenceNumber', pos=22, end=14290 ]
    [ parse fixed, Fog#460, count=0 ]
    [ - matched data 22 to 27: "00001" ]
    [ - parse: result=1 ]
    [ - parse: 'SequenceNumber' , done=false, pos=27, end=14290, last=EOD ]
    [ parse 'StockNoticeNumber', pos=27, end=14290 ]
    [ parse fixed, Fog#462, count=0 ]
    [ - matched data 27 to 47: "49545100000100000000" ]
    [ - parse: result=1 ]
    [ - parse: 'StockNoticeNumber' , done=false, pos=47, end=14290, last=EOD ]
    [ parse 'CurrentDate', pos=47, end=14290 ]
    [ parse fixed, Fog#469, count=0 ]
    [ - matched data 47 to 67: "                    " ]
    [ - parse: result=1 ]
    [ - parse: 'CurrentDate' , done=false, pos=67, end=14290, last=EOD ]
    [ parse 'SequenceNumber:2', pos=67, end=14290 ]
    [ parse fixed, Fog#471, count=0 ]
    [ - matched data 67 to 72: "00001" ]
    [ - parse: result=1 ]
    [ - parse: 'SequenceNumber:2' , done=false, pos=72, end=14290, last=EOD ]
    [ parse 'RecvStoreNumber', pos=72, end=14290 ]
    [ parse fixed, Fog#473, count=0 ]
    [ - matched data 72 to 89: "0000115888       " ]
    [ - parse: result=1 ]
    [ - parse: 'RecvStoreNumber' , done=false, pos=89, end=14290, last=EOD ]
    [ parse 'SchedSendDate', pos=89, end=14290 ]
    [ parse fixed, Fog#475, count=0 ]
    [ - matched data 89 to 98: "080108   " ]
    [ - parse: result=1 ]
    [ - parse: 'SchedSendDate' , done=false, pos=98, end=14290, last=EOD ]
    [ parse 'CreationDate', pos=98, end=14290 ]
    [ parse fixed, Fog#477, count=0 ]
    [ - matched data 98 to 107: "080108   " ]
    [ - parse: result=1 ]
    [ - parse: 'CreationDate' , done=false, pos=107, end=14290, last=EOD ]
    [ parse 'CreationTime', pos=107, end=14290 ]
    [ parse fixed, Fog#677, count=0 ]
    [ - matched data 107 to 113: "091212" ]
    [ - parse: result=1 ]
    [ - parse: 'CreationTime' , done=false, pos=113, end=14290, last=EOD ]
    [ parse 'RefNoticeNum', pos=113, end=14290 ]
    [ parse fixed, Fog#547, count=0 ]
    [ - matched data 113 to 133: "4954510             " ]
    [ - parse: result=1 ]
    [ - parse: 'RefNoticeNum' , done=false, pos=133, end=14290, last=EOD ]
    [ parse 'ASN', pos=133, end=14290 ]
    [ parse fixed, Fog#679, count=0 ]
    [ - matched data 133 to 136: "ASN" ]
    [ - parse: result=1 ]
    [ - parse: 'ASN' , done=false, pos=136, end=14290, last=EOD ]
    [ parse 'TRANSACTION_ID', pos=136, end=14290 ]
    [ parse fixed, Fog#681, count=0 ]
    [ - matched data 136 to 164: "ASN08010849545100..." ]
    [ - parse: result=1 ]
    [ - parse: 'TRANSACTION_ID' , done=false, pos=164, end=14290, last=EOD ]
    [ - retry parent delimiter ]
    [ - retry failed: overshoot, del=289, pos=0 ]
    [ - parse: result=0 ]
    [ - for #2: count=-1 ]
    [ - parse: result=0 ]
    [ - parse: 'recordGroup' , done=false, pos=0, end=14290, last=EOD ]
    [ - for #1: count=0 ]
    [ - parse: result=1 ]
    [ - parse: 'otdInput' , done=false, pos=0, end=14290, last=EOD ]
    [ - for #0: count=1 ]
    What should I do to correct this?
    Thanks & Kind Regards,
    Richard

    Can you tell me a quick summary of what you do did to solve this? I am having a similar error.

  • Newbie - help needed with array and dictionary objects

    Hi all
    Please see the code below. I've posted this code in another thread however the original issue was resolved and this is now a new issue I'm having although centered around the same code.
    The issue is that I'm populating an array with dictionary objects. each dictionary object has a key and it's value is another array of custom objects.
    I've found that the code runs without error and I end up with my array as I'm expecting however all of the dictionary objects are the same.
    I assume it's something to do with pointers and/or re-using the same objects but i'm new to obj-c and pointers so i am a bit lost.
    Any help again is very much appreciated.
    // Open the database connection and retrieve minimal information for all objects.
    - (void)initializeDatabase {
    NSMutableArray *authorArray = [[NSMutableArray alloc] init];
    self.authors = authorArray;
    [authorArray release];
    // The database is stored in the application bundle.
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"books.sql"];
    // Open the database. The database was prepared outside the application.
    if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
    // Get the primary key for all books.
    const char *sql = "SELECT id, author FROM author";
    sqlite3_stmt *statement;
    // Preparing a statement compiles the SQL query into a byte-code program in the SQLite library.
    // The third parameter is either the length of the SQL string or -1 to read up to the first null terminator.
    if (sqlite3preparev2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
    // We "step" through the results - once for each row.
    // We start with Letter A...we're building an A - Z grouping
    NSString *letter = @"A";
    NSMutableArray *tempauthors = [[NSMutableArray alloc] init];
    while (sqlite3_step(statement) == SQLITE_ROW) {
    author *author = [[author alloc] init];
    author.primaryKey = sqlite3columnint(statement, 0);
    author.title = [NSString stringWithUTF8String:(char *)sqlite3columntext(statement, 0)];
    // FOLLOWING WAS LEFT OVER FROM ORIGINAL COMMENTS IN SQLBooks example....
    // We avoid the alloc-init-autorelease pattern here because we are in a tight loop and
    // autorelease is slightly more expensive than release. This design choice has nothing to do with
    // actual memory management - at the end of this block of code, all the book objects allocated
    // here will be in memory regardless of whether we use autorelease or release, because they are
    // retained by the books array.
    // if the author starts with the Letter we currently have, add it to the temp array
    if ([[author.title substringToIndex:1] compare:letter] == NSOrderedSame){
    [tempauthors addObject:author];
    } // if this is different letter, then we need to deal with that too...
    else {
    // create a dictionary to store the current tempauthors array in...
    NSDictionary *tempDictionary = [NSDictionary dictionaryWithObject:tempauthors forKey:@"authors"];
    // add the dictionary to our appDelegate-level array
    [authors addObject:tempDictionary];
    // now prepare for the next loop...
    // set the new letter...
    letter = [author.title substringToIndex:1];
    // remove all of the previous authors so we don't duplicate...
    [tempauthors removeAllObjects];
    // add the current author as this was the one that didn't match the Letter and so
    // never went into the previous array...
    [tempauthors addObject:author];
    // release ready for the next loop...
    [author release];
    // clear up the remaining authors that weren't picked up and saved in the "else" statement above...
    if (tempauthors.count > 0){
    NSDictionary *tempDictionary = [NSDictionary dictionaryWithObject:tempauthors forKey:@"authors"];
    [authors addObject:tempDictionary];
    else {
    printf("Failed preparing statement %s
    ", sqlite3_errmsg(database));
    // "Finalize" the statement - releases the resources associated with the statement.
    sqlite3_finalize(statement);
    } else {
    // Even though the open failed, call close to properly clean up resources.
    sqlite3_close(database);
    NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database));
    // Additional error handling, as appropriate...
    Message was edited by: dotnetter

    Ok, so I know what the issue is now...I just don't know enough to be able to resolve it!
    it's the tempAuthors objects.
    It's an NSMutableArray which is create on the line before the start of the WHILE loop.
    Having looked through the debugger, I can see that each dictionary object is created (with different codes which I assume are memory addresses) so all is well there. However, on each iteration of the loop in the middle there is an IF...ELSE... statement which in the ELSE section is clearing all objects from the tempAuthors array and beginning to repopulate it again.
    Looking at the containing dictionary objects in the debugger I can see that the tempAuthors object that each contains has the same code (again, I'm assuming this is a memory address) - so if I understand correctly, it's the same object...I assumed that when I created the dictionary using the dictionWithObject call that I would be passing in a copy of the object, but it's referencing back to the object which I then go on to change.
    Assuming the above is correct, I've tried several "stabs in the dark" at fixing it.
    I've tried relasing the tempAuthors object within the ELSE and initialising it again via an alloc...init - but this didn't work and again looking through the debugger it looks as though it was confused as to which object it was supposed to be using on the following iteration of the WHILE loop (it tried to access the released object).
    Having read a little more about memory management can someone tell me if I'm correct in saying that the above is because the tempAuthors object is declare outside the scope of the WHILE loop yet I then try to re-instantiate it within the loop (does that make sense???).
    Sorry for the long post...the more I can understand the process the less I can hopefully stop relying on others for help so much.
    I am continuing to read up on memory management etc but just not there yet.
    Regards
    Wayne

  • [svn:osmf:] 14306: PARB changes: Merge seekBegin and seekEnd event types into a single seekingChange event type .

    Revision: 14306
    Revision: 14306
    Author:   [email protected]
    Date:     2010-02-21 10:48:21 -0800 (Sun, 21 Feb 2010)
    Log Message:
    PARB changes: Merge seekBegin and seekEnd event types into a single seekingChange event type.  Add seeking as a getter to the SeekEvent class.  Update test code and samples accordingly.
    Modified Paths:
        osmf/trunk/apps/samples/framework/CuePointSample/src/CuePointSample.mxml
        osmf/trunk/apps/samples/framework/DynamicStreamingSample/src/DynamicStreamingSample.mxml
        osmf/trunk/apps/samples/plugins/AkamaiPluginSample/src/AkamaiPluginSample.mxml
        osmf/trunk/apps/samples/plugins/CaptioningSample/src/CaptioningSample.mxml
        osmf/trunk/framework/OSMF/.flexLibProperties
        osmf/trunk/framework/OSMF/org/osmf/elements/DurationElement.as
        osmf/trunk/framework/OSMF/org/osmf/elements/ListenerProxyElement.as
        osmf/trunk/framework/OSMF/org/osmf/elements/compositeClasses/CompositeSeekTrait.as
        osmf/trunk/framework/OSMF/org/osmf/elements/compositeClasses/ParallelSeekTrait.as
        osmf/trunk/framework/OSMF/org/osmf/events/MediaErrorEvent.as
        osmf/trunk/framework/OSMF/org/osmf/events/SeekEvent.as
        osmf/trunk/framework/OSMF/org/osmf/media/MediaPlayer.as
        osmf/trunk/framework/OSMF/org/osmf/metadata/TemporalFacet.as
        osmf/trunk/framework/OSMF/org/osmf/traits/SeekTrait.as
        osmf/trunk/framework/OSMF/org/osmf/utils/TraitEventDispatcher.as
        osmf/trunk/framework/OSMFTest/org/osmf/elements/TestDurationElement.as
        osmf/trunk/framework/OSMFTest/org/osmf/elements/TestParallelElementWithSeekTrait.as
        osmf/trunk/framework/OSMFTest/org/osmf/elements/audioClasses/TestAudioSeekTrait.as
        osmf/trunk/framework/OSMFTest/org/osmf/media/TestMediaPlayer.as
        osmf/trunk/framework/OSMFTest/org/osmf/traits/TestSeekTrait.as
        osmf/trunk/framework/OSMFTest/org/osmf/utils/DynamicSeekTrait.as
        osmf/trunk/framework/OSMFTest/org/osmf/utils/TestTraitEventDispatcher.as
        osmf/trunk/libs/ChromeLibrary/src/org/osmf/chrome/controlbar/widgets/RecordButton.as
        osmf/trunk/plugins/CaptioningPluginTest/src/CaptioningPluginTest.mxml
        osmf/trunk/plugins/MASTPlugin/org/osmf/mast/adapter/MASTAdapter.as
        osmf/trunk/plugins/MASTPlugin/org/osmf/mast/managers/MASTConditionManager.as

    ls -l /var/run/lighttpd/
    And how are you spawning the php instances? I don't see that in the daemons array anywhere.
    EDIT: It looks like the info in that page is no longer using pre-spawned instances, but lighttpd adaptive-spawn. The documentation has been made inconsistent it looks like.
    You will note that with pre-spawned information, the config looks different[1].
    You need to do one or the other, not both (eg. choose adaptive-spawn, or pre-spawn..not both).
    [1]: http://wiki.archlinux.org/index.php?tit … oldid=8051 "change"

  • Merge /opt and /var filesystem.

    We have Solaris 2.6 running on one of our production Servers(Sun E450).
    For some reasons we need to merge /opt and /var partitions, so that we can free one slice for our use. What are the suggested methods in which this can be done with minimum downtime ? Also I would like to know the repercussions if any ?

    Hi Ernesto,
    Please check the timestamp for the crash files under /var. Delete the older ones as even the OS support group may not analyze any older crash dump files.
    Or
    Move these crash dump files to new location where you have enough space.
    Regards,
    Deepak Kori

  • Merging item and condition records

    Hi All,
    I have a requirement to merge item and conditon data . I am using 2LIS_11_VAITM & 2LIS_11_VAKON .
    The key for booking DSO are document number, item number AND calendar day.  I am concerned that we cannot easily link up the records from one DSO to the other, since they are date and even activity dependent.  For example, if more than one change is made to the value of the item in one day, then the condition values will also be different for each change.
    Please suggest on how to go ahead .
    Thanks

    The best thing is to load these datasources to 2 DSOs and then to a Cube.
    One option could be having a consolidation DSO on top of these two, having multiple rule groups to convert the data model from Account based to Key figure based for Conditions data.  You will have multiple condition records for a Sales order item. Order, item & condition type should ideally be the key for the DSO). When loading Conditions to the Consolidation DSO (this would have Order, item as key) you would have multiple transformation rule groups so that key figure from each condition record is updated to one key figure in the DSO. There could be may condition records and there could be new additions in ECC, then you would have to change the objects again. This, I guess is not a good model.
    Enhancing VAITM is not a good option as there would be many condition records for an order item.
    Edited by: Murali Krishna K on Jul 28, 2011 12:01 PM

  • How to merge arrays?

    How do i write a merge method that takes two arrays of int, merges the two into one large array that contains the ele,ents of both arrays and returns the large array. The method is missing in the dotted area. How do i declare C and than return C?
    class ArrayMerge
    public static void main(String[] args) {
    int[] A = {0, 1, 2, 3, 4};
    int[] B = {5, 6, 7, 8, 9};
    int[] C = merge(A, B);
    for (int i = 0; i < C.length; ++i)
    System.out.println(C);
    public static int[] merge(int[] A, int[] B) {

    How do i write a merge method that takes two arrays of
    int, merges the two into one large array that contains
    the ele,ents of both arrays and returns the large
    array. The method is missing in the dotted area. How
    do i declare C and than return C?It's very straightforward. Just make a new array and copy the two arrays into it (I haven't actually tested it though),
    public int[] merge(int[] A, int[] B) {
        int[] C = new int[A.length+B.length];
        int j=0;
        for (int i=0; i<A.length; i++)
            C[j++] = A[ i];
        for (int i=0; i<B.length; i++)
            C[j++] = B[ i];
        return C;

  • Search given string array and replace with another string array using Regex

    Hi All,
    I want to search the given string array and replace with another string array using regex in java
    for example,
    String news = "If you wish to search for any of these characters, they must be preceded by the character to be interpreted"
    String fromValue[] = {"you", "search", "for", "any"}
    String toValue[] = {"me", "dont search", "never", "trip"}
    so the string "you" needs to be converted to "me" i.e you --> me. Similarly
    you --> me
    search --> don't search
    for --> never
    any --> trip
    I want a SINGLE Regular Expression with search and replaces and returns a SINGLE String after replacing all.
    I don't like to iterate one by one and applying regex for each from and to value. Instead i want to iterate the array and form a SINGLE Regulare expression and use to replace the contents of the Entire String.
    One Single regular expression which matches the pattern and solve the issue.
    the output should be as:
    If me wish to don't search never trip etc...,
    Please help me to resolve this.
    Thanks In Advance,
    Kathir

    As stated, no, it can't be done. But that doesn't mean you have to make a separate pass over the input for each word you want to replace. You can employ a regex that matches any word, then use the lower-level Matcher methods to replace the word or not depending on what was matched. Here's an example: import java.util.*;
    import java.util.regex.*;
    public class Test
      static final List<String> oldWords =
          Arrays.asList("you", "search", "for", "any");
      static final List<String> newWords =
          Arrays.asList("me", "dont search", "never", "trip");
      public static void main(String[] args) throws Exception
        String str = "If you wish to search for any of these characters, "
            + "they must be preceded by the character to be interpreted";
        System.out.println(doReplace(str));
      public static String doReplace(String str)
        Pattern p = Pattern.compile("\\b\\w+\\b");
        Matcher m = p.matcher(str);
        StringBuffer sb = new StringBuffer();
        while (m.find())
          int pos = oldWords.indexOf(m.group());
          if (pos > -1)
            m.appendReplacement(sb, "");
            sb.append(newWords.get(pos));
        m.appendTail(sb);
        return sb.toString();
    } This is just a demonstration of the technique; a real-world solution would require a more complicated regex, and I would probably use a Map instead of the two Lists (or arrays).

Maybe you are looking for