Remove duplicates and add to collection totals ArrayCollection

Is there a function that removes duplicates from a table collection and totals a value where duplicates?

For example Array

[Name: John, value: 2]

[Name: Dave, value: 10]

[Name: John, value: 2]

[Name: Dave, value: 8]

[Name: Dave, value: 2]

[Name: John, value: 1]

Output should be:

Name: John value: 5

Name: Dave value: 20

Thank you very much - I really need help with this, I can not logic.

Thank you

Please try this,

private void filterData(event: MouseEvent): void {}
var source: collection ArrayCollection = new ArrayCollection();
source.addItem ({name: "John", value: 2});
source.addItem ({name: "Dave", value: 10});
source.addItem ({name: "John", value: 2});
source.addItem ({name: "Dave", value: 8});
source.addItem ({name: "Dave", value: 2});
source.addItem ({name: "John", value: 1});
   
var result: collection ArrayCollection = new ArrayCollection();
var flag: Boolean;
for (var i: int = 0; i)< source.length;="" i++)="">
flag = false;
for (var j int = 0; j< result.length;="" j++)="">
If (result.getItemAt (j) ['name'] is {source.getItemAt (i) ["name"])}
result.getItemAt (j) ['value'] is (result.getItemAt (j) ['value'] + source.getItemAt (i) ["value"]);.
flag = true;
break;
}
}
If (! flag) {}
result.addItem (source.getItemAt (i));
}
}
for (var K:: int = 0; k)< result.length;="" k++)="">
Alert.Show (result.getItemAt (k) ['name'] + '-' + (k) result.getItemAt ["value"]);
}
}

Tags: Flex

Similar Questions

  • I have windows vista on this computer and I want to remove it and add windows xp.

    I have Windows Vista on this computer and I want to remove it and replace it with Windows XP Professional.  Whenever I tried to do, I succumbed. I tried to just boot from the cd and install xp and it tells me that the version on the computer is newer than the one I am trying to install and then gives me no option besides. I left and I restarted in safe mode and the command propt tried to fdisk and he said no authorized for this.  When I try to format it is said that volume id and I don't know who.  I've never been so lost trying to remove a platform in my life.  I would like to have an answer to this problem, thanks and have a blessed day, Robin

    Hi Robin,

    ·         What is the type of disc you are having? It's a drive to upgrade or full version?

    ·         How many partitions are present on the computer?

    ·         Why would you downgrade from Windows Vista to Windows XP?

    You need demarrer start from the installation disc, choose the partition where Windows is installed (ideally the C drive). Format it and then go to the Windows XP installation.

    Let us know if you need more assistance.

  • Grep to remove parentheses and add dash here

    Hi guys,.

    I have long paragraph Notes with parenthesis between the numbers.  Here is the sample photo

    grep indent to here.jpg

    How can I write a GREP command for

    (1) remove all parentheses in the list (as in the example number 1 in the text)

    (2) add a space after the number

    (3) add the Indent here at the beginning of the text.

    If it's too complicated just with the removal of the brackets would be great!

    Thanks for any help and best!

    S

    Your typical grep added a tab and a return. My grep has added to the tab.

    If you want to use the indent to here instead, try to use this to replace it:

    $2 ~ m ~ I

    This will give you the number, an m-space and character dash out.

  • Remove duplicates and fix a join table

    Oracle 10.2 g

    I have two tables and a table of junction between them.

    Table_a
    name identity
    1 TEST
    2 OF TEST2
    TEST 3

    Table_B
    ID
    1
    2
    3
    4

    TableA_TO_B
    A_ID b_id
    5 5
    1 2
    3 3

    Duplicates could not in table A, but the unique constraint has been accidentally disabled.

    So I want to be able to do is to remove all duplicates of table A, and if there is no line in
    TableA_TO_B that contain identifiers should be deleted, I want to update this line to refer to the now single
    TableA line.

    I am able to find duplicates by practice

    Select the id of the table_a where rowid > (select min (rowid) in the b table_a where b.SID = b.name)

    But after that I'm stuck.

    Hello...

    There may be a more elegant way to do this, rather than create an intermediate table, but... (note that this is NOT tested and may need some tuning/indexing on the staging table if you operate on large data sets!) :

    (1) create a temporary table by storing the ID to keep (and thus the value updated in TableA_B) - Note This code assumes that the folder with the ID (MIN) low will be the value stored in TableA...

    create table tmp nologging as
    select id,name,min(id) over (partition by name) ID_TO_KEEP
    from table_a;
    

    (2) execute the update statement, by changing the values that must be maintained (i.e. no are NOT deduplicated):

    update tablea_b ab
    set a_id = (select id_to_keep from tmp where id=ab.id);
    

    (3) perform the delete duplicates deleting statement in TableA (NOTE: assumes that you do not have etc. funky foreign key constraints on tables!):

    delete from table_a a where EXISTS (select id from tmp where id=a.id and id<>id_to_keep);
    

    I hope that works for you...! ;-)

  • How to identify and remove duplicates and files in Windows 7 and those who are not the files in Win 7

    I used a program called IntelliMover and think that it flies over the files and unnecessary files.  How can I identify and delete these files?

    If make sure you that the files are not used by some programs or windows, then, the answer is YES.
    Easier would be, just look for duplicates in the folders where the files are not required by Windows or programs.

  • How many machines can not I down load my product too? And how to remove one and add it to another?

    How many machines can not I down load my product too?

    You can install your software on two computers. (You can not run the software simultaneously on both computers, however.) If you want to install on an additional computer, you must disable one of previous installations. More information is in Activation, deactivation. Adobe products.

  • need to remove duplicate rows from a table

    Hi gurus,

    I'm using oracle 11.2.0.3.

    SQL > desc osstage. S_EVT_ACT_X;

    Name                                      Null?    Type

    ----------------------------------------- -------- ----------------------------

    ROW_ID NOT NULL VARCHAR2 (15 CHAR)

    LAST_UPD NOT NULL DATE

    PAR_ROW_ID NOT NULL VARCHAR2 (15 CHAR)

    ATTRIB_17 NUMBER (22.7)

    DATE OF ATTRIB_26

    ATTRIB_02 VARCHAR2 (100 CHAR)

    PROCESS_TIMESTAMP TIMESTAMP (6);

    now, when I give the command below, it gives error as someone has disabled the constraint accidentally.

    change the table s_evt_act_x S_EVT_ACT_X_P1 enable constraint;

    Error from line 3 in order:

    change the constraint of table s_evt_act_x activate S_EVT_ACT_X_P1

    Error report:

    SQL error: ORA-02437: impossible to validate (OSSTAGE. S_EVT_ACT_X_P1) - primary key violated

    02437 00000 - "can't validate (s.%s) - primary key violated."

    * Cause: attempted to validate a primary key with duplicate values or null

    values.

    * Action: remove duplicates and nulls before enabling a primary

    key.

    You can guide me please with this question.

    Please see

    Script: Remove the duplicate of a Table (Doc ID 31413.1) lines

    How to find or remove the duplicate in a Table (Doc ID 1004425.6) lines

  • Access table in the arraycollection collection and add the item at the end of the table

    for
    
    
    "login_user":"XXX"},i);
    
    //mess2=sess_MessArr[i2];
    //mess1=dispArray[i2].fwchat_message
    
    //searchArray(mess2);}
    
    
    
    
    
    (var i:int = 0; i< dispArray.length; ++i){
    
    dispArray[i]. 
    dispArray.addItemAt({
    


    I have this code to try to access the values in the table in the arraycollection collection, but that's not it actually creates a value at the end of the arraycollection collection. can someone tell me what im doing wrong I basically want retransmits the individual tables in the arraycollection collection and add Login_user

    So, I guess your ArrayCollection collection holds an array of objects, as follows:

    public var myAC:ArrayCollection = new ArrayCollection([{first:"bob",last:"smith"},{first:"jim",last:"jones"},{first:"mary",last:"allen"}]);
    

    And you try to add a new property of login_user to each of them, right?

    for each (var obj:Object in myAC) {
         obj.login_user = obj.first + "83";
    }
    

    Each person would be firstly, properties last and login_user.  In my example above, all the login_user would set their name + number 83, so adjust you accordingly for your application.

    It is the ease (for each rock for this situation).  However, if you want to paste the iterative approach, you have published, you can try this:

    for (var i:int = 0; i < myAC.length; i++) {
         myAC.getItemAt(i).login_user = myAC.getItemAt(i).first + "83";
    }
    

    I think that the for each syntax is clearer, but anyway works the way I think you want.

  • To check and remove duplicate records

    Hi guys,.

    I have a T1 table where my col_1, col_2, col_3 columns are primary keys and the table is to have a huge volume of data recorded about 200 billion. Before you add the primary key, I need to check if there are duplicates and then delete these records. Who will be fastest way to check, I used below

    Select * from T1

    where rowid in (select rn (INF. Select rowid,

    DENSE_RANK() on ln (score of col1, col2, col3 order by rowid)

    from T1)

    where ln <>1);

    Is there another way using the analytical function can be faster to access the records of 200 billion

    Sven wrote:

    Instead of making a deletion consider to re-create the table using only the unique values. Very often, it's much faster than a delete even if more data is moved, but as always, it depends.

    It would be useful if you know how many lines you have and how duplicates are for example (the number of records is removed).

    Also, you should have a comparable test database, which is not always easy to have with large datasizes are invloved.

    Yes, Sven is quite right, ETG might actually be faster to remove duplicates of the original. But you will need to investigate the volume of data.

    create table T2 as

    Select col1, col2, col3,..., coln - all original columns except rn

    from (select t.*, row_number() on rn (score of col1, col2, col3 order by rowid)

    t)

    where rn = 1

    /

    Then hover over any constraint, etc. and drop T with purge, rename T2 in T.

  • 3.6.2 the numbers help find and remove duplicates in 2 columns

    Could someone help me please. I run a karaoke business. As you may have guessed I have books with many songs, 64 000 and more than 75% of these songs are duplicates so you can imagine by train to sort. Option 1 I could manually go through my list by removing duplicates or option 2 attempt to find a formula that works save me hours of blind deletion. Is there someone out there who can help? It would be much appreciated thanks.

    Here is a sample of the document I'm working.

    Hi robi.

    Here is a solution of Craig s. Ruddock in this discussion Re: duplicates warning formula

    Formula in B2 (fill down)

    = IF (COUNTIF($A,A) = 1",","duplicate")

    Now sort by column A

    Remove all but one of the "duplicate" lines for each song.

    Kind regards

    Ian.

  • I can't uninstall Firefox. I tried my Add/Remove programs and have tried the intsruction given to manually run C:\Program Files\Mozilla Firefox\uninstall\helper.exe. and it won't work. Firefox is the only program that I am not able to uninstall u

    I am unable to uninstall Firefox. I have tried my add/remove programs and have tried the intsruction given to manually run C:\Program Files\Mozilla Firefox\uninstall\helper.exe. and it will not run. Firefox is the only program I am not able to uninstall using the normal methods
    

    This has happened

    Just once or twice

    today

    User Agent

    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SIMBAR = {357DAD02-321A-4E1D-8305-C8CE3D8CA934}; .NET CLR 1.0.3705; .NET CLR 1.1.4322;. Media Center PC 2.8; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152 .NET CLR 3.5.30729)

    I ' v tried running C:\Program Files\Mozilla Firefox\uninstall\helper.exe.
    It does not work.

  • A friend gave me his old iPad. How to remove his account and add it to my Apple account?

    A friend gave me his old iPad. How to remove his account and add it to my Apple account?

    Hi and welcome to the community!

    Follow the instructions below:

    Turn off find my iPhone Activation Lock - Apple Support

  • What is"safe" to remove in my add and remove programs?

    What is 'safe' to remove in my add and remove programs?

    As the "Show updates" box is NOT checked, pretty much everything shown in Add / Remove programs other than "Windows Service Pack 3" is safe to delete.

    If you'll be glad later is another story.

    If you don't know what a given application, you can either Google it or ask here and someone will probably be able to tell you what it is and if it is likely that any other thing depends on the application.  For example, it is 'safe' remove the different versions of Microsoft .NET Framework, but this would almost certainly result in another application no longer able to function.

  • im running xp and Add/Remove programs will not let me delete all programs

    im running xp and Add/Remove programs will let me delete all programs, nor does it show all of my programs

    Hello

    · You receive an error message or error code when you try to uninstall the program?

    · Were there any changes made on the computer before the show?

    Run the fix it from the link: Add/Remove Programs displays installed the tool incorrectly: http://support.microsoft.com/kb/266668

    Add to that, I suggest to run online virus scan and check if any malware or virus detected on the computer activity. You can run the scan for viruses online from the link below: http://www.microsoft.com/security/scanner/en-us/default.aspx

    NOTE: Make sure that you select the correct version of the operating system before downloading the scanner)

  • How to: Restore my back of laptop for buying condition, remove Google and all add ons

    Original title: Restore my back of laptop for buying condition, remove Google and all add ons

    Vista
    Inspiron 1525
    Centrino Inside
    Reference Dell
    Laptop
    2008
    Delete all the shortcuts, folders, data of the necessary United Nations
    system restore

    Hello

    As you ask here, you don't have a recovery disk.

    Here's how to access the Dell recovery hard disk partition and put your computer about how you bought.

    ATTENTION: All your data and programs that you have installed will be wiped from the drive hard as you do this. so back up your data. Programs will need to be reinstalled.

    http://support.Dell.com/support/topics/global.aspx/support/KCS/document?c=us&l=en&s=Gen&docid=DSN_336966&isLegacy=true

    See you soon.

Maybe you are looking for