LinkedList - printing non-repeated occurrences

I have to read some data from a file. Each line is in the following format: ID_number;Name;address.
Store it and then print all the occurrences that are not repeated.
If the file had the following lines:
+12345;John;California+ <-- repeated ID
+3243243;Marie;Mars+
+12345;Jane;Madrid+ <--- repeated ID
+4344444;Jill;US+
I would print:
+3243243;Marie;Mars+
+4344444;Jill;US+
Since I don't know how many lines the file has I was thinking about using a LinkedList to store the values
instead of an array but I do not know of any efficient way to remove the repeated occurrences or just print
the non-repeated.
I'm quite new to Java. If someone could point me in the right direction I would appreciate it.

This is how I did it. Works but I am not sure if it is the best way to do it.
import java.util.LinkedList;
public class TestFile {
     public static void main(String[] args) {
          LinkedList<String> llist = new LinkedList<String>();
          llist.add("23167;sadas sd d;asdasd Dfffd");
          llist.add("12345;sdas s sd;asd sd sasd");          // repeated
          llist.add("443324;sadasd;Asdasd");
          llist.add("12345;sGadasd;Asdd sd ssad");          // repeated
          String[] v = llist.toArray(new String[0]);          // LinkedList to Array
          boolean dupFound = false;
          // sets repeated occurrences to null
          for (int i = 0; i < v.length - 1; i++) {
               dupFound = false;
               if (v[i] != null) {
                    for (int j = i + 1; j < v.length; j++) {
                         if (v[j] != null && v.split(";")[0]
                         .equals(v[j].split(";")[0])) {
                              v[j] = null;
                              dupFound = true;
                    } //inner for
                    if (dupFound) {
                         v[i] = null;
          } //outer for
          // print non-repeated occurrences
          for (int i = 0; i < v.length; i++)
               if (v[i] != null)
                    System.out.println(v[i]);
     } //end main
} //end classBeen reading about Sets through that link and the API. Still no clue of which path to
follow. I'll try googling a bit to see if I can get enlighted.
Thank you for the help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Lost Calendar appointments (only non-repeated evnets)

    I have trouble in my Palm Z22 , Palm Desktop 4.2@Windows XP.
    I recently found all the NON-REPEATED Data from yr 2003 to mid 2008 has gone whereas the repeated data during the period are intact. Besides, data before yr 2003 and after June 2008 are alright. The situation is similar to another thread http://forums.palm.com/palm/board/message?board.id=windows_hotsync&message.id=34943
    I have backup copy of files "DateBook.bak", "DateBook.mdb" in Feb 2008, which might be created by another version of Palm Desktop. I know that under my current Palm Desktop 4.2, the working file should be "datebook.dat".
    How can I extract data from "DateBook.bak", "DateBook.mdb" so that it is readable to Palm Desktop 4.2?
    Thanks!
    Post relates to: Palm Z22

    You can recover the data from your user folder provided you have only sync'ed once with the PC when you discovered the data missing. When you sync to the PC there are files created for each PIM category in your user folder. For Example; datebook.dat or datebook (Depending on the version of Palm Desktop) and datebook.bak. Using 6.2 the file names are .mdb and mdb.bak. For 6.2, the files are located in the username folder in PalmOSdesktop in my documents.
    The files are named .dat and .bak. When you sync, the current data is stored in .dat. The next time you sync the data in the .dat file is copied to the .bak file. You can rename the .dat to .old. then rename the .bak to .dat. If the data in the .bak file is intact, it will now be in palm desktop when you reopen Palm desktop. I have included a link to show you how to find the userfolder on the PC.
    http://www.palm.com/cgi-bin/cso_kbURL.cgi?ID=26674
    Here is another link regarding data loss;
    http://www.palm.com/cgi-bin/cso_kbURL.cgi?ID=39503
    The best way to backup your data is to use the export feature in Palm Desktop. Make a new folder on the PC desktop named Palm Desktop Backup data. Next, select the category you want to export. You will get a window that asks where you want to save the file, save in the folder created on the desktop. There is a button that allows you to select currently selected record or all, select all. If you don't select all, then only the record highlighted is exported. You will then need to name the file for export, I suggest the name of the category, eg: datebook (With current date). Do this for all critical data in each category. With the data exported to the folder on the PC desktop, you can save this data to a flash drive, external hard drive or a CD-RW. With this method you will have your data in a seperate place than Palm desktop and the device. If you "Lose" data again, you can import the data back into palm desktop.
    Make sure that when you make changes in palm desktop or the device to export the data to the folder created for the backup.
    Here is a link for other options for backing up your data;
    http://www.palm.com/cgi-bin/cso_kbURL.cgi?ID=28751
    Post relates to: Palm i705

  • Can't able to print Non English data properly in PDF Output

    Can't able to print non english data properly
    Example:
    I want to print the germen data (Währung),But it printing like this (Währung) in PDF out put
    What the changes i have to do to achive this
    Thanks&regards
    yamini

    Hi Yamini,
    I think this happens when you look at utf-8 in Windows wiith another character set. I've noticed that the XML file (and hence the PDF output) displays those characters when I preview reports on the BI desktop, but the output from the server is fine, so I don't worry about it.
    Tore.

  • Creating Non-Repeating fields

    Hello all,
    I am creating a query that lists a bunch of student ID's and their schedules. However, the ID's of students should only show on the first row of thier schedule. I've figured out a way to do it with the Lag function, but I was wondering if there is a better way or if this is the only way? Also, does this "method" have a name?
    For example, instead of:
    Student ID    Course
      3823481     Math 101
      3823481     English 201
      3823481     History 230
      5293012     Art 402
      5293012     English 301
      5293012     CGT 212I want this to show:
    Student ID    Course
      3823481     Math 101
                  English 201
                  History 230
      5293012     Art 402
                  English 301
                  CGT 212This is kind of what my code looks like:
      -- Non-repeating PNumber
           Case Lag (ID) over (order by ID)
             When ID Then ' '
             Else ID
            End as Student_ID,
      -- List Classes
           Course_Title
      From (...)
      Where (...)

    Hi ..
    a possible solution:
    with q as(
    select 3823481 Student_ID ,'Math 101' Course from dual union all
    select 3823481    ,'English 201' from dual union all
    select 3823481     ,'History 230' from dual union all
    select 5293012     ,'Art 402' from dual union all
    select 5293012    ,'English 301' from dual union all
    select 5293012    ,'CGT 212' from dual)
    select decode(row_number() over (partition by Student_ID order by course),1,Student_ID) Student_ID,course from q

  • Non repeating frame - when/how to use

    Hi,
    How do I use a non repeating frame on it's own.
    I have one query in which I have selected 3 fields.
    In the paper layout, I have placed 3 fields in a non repeating frame.
    When I run the report, I get a REP-1213 error - Filed 'xxx' at frequency below its group.
    When I place the 3 fields ina repeating frame, it works, because the repeating frame property inspector allows me to enter the group and the non repeating frame does not.
    So, my question is, when and how does one use a non repeating frame.
    I need to understand the principle behind it.
    Thank you
    i

    You mainly use regular frames to group objects together or prevent them from being overwritten. Check the help on About Frames.

  • Printing Non Excisable Return Delivery

    Dear Experts,
    Pl. send me the step by step procedure to print Non excisable Return Delivery document .
    Is there any customization need to be checked .
    Also what are the steps to be followed to print the document?
    Regards,
    AK

    Hi,
    I case of vendor return, go to MIGO - Return delivery > Material Document (Here refer GR doc, system will determine Movement Type "122" automatically). And select Print Version as "3" and activate "Print" indicator in "General" Tab of MIGO at Header Level.
    And in case of Non-Excisable material, you don't have to do J1IS (Vendor Excise Invoice) so there will not be printing of Excise invoice through J1IV.
    Here you have to print material document in MB90, for which you have to check following configurations;
    1. OMBR - Here Click on "Print Indicator" button and assign Print Version as "3" (Collective Slip) to Transaction MIGO.
    2. OMB5 - Assign Print Item as "2" (Return Delivery)
    3. M706 - Use any for the following condition types;
    WA01     GI Note Vers.1
    WA02     GI Note Vers.2
    WA03     GI Note Vers.3
    4. MN21 - Create Condition Record for any of the above Condition Type

  • Does ne1 now the html code to set a background image=non repeat, center for dreamweaver or where to find it?

    Im trying to set up an about me page like that of myspace.com
    i know that in myspace you can set the background image center non
    repeat can this be done as will with dreamweaver?

    Hello,
    Yes, it can be done using CSS.
    You can place this in your code, right before </head>.
    Just substitute your image for mypicture.jpg.
    <style type="text/css">
    <!--
    body {
    background-image: url(mypicture.jpg);
    background-repeat: no-repeat;
    background-position: center center;
    -->
    </style>
    -OR-
    You can also do this using DW's dialog boxes (like a wizard).
    If you have DW8 or CS3...or MX2004 if memory serves, you can
    right click on
    your page in design view.
    Select CSS Styles > New
    A CSS Rule dialog box opens.
    Select tag, then in the tag box, type body.
    You can select whether you want to add the CSS to this page
    (like the code
    above) or to a stylesheet linked to this page. If you are
    going to use CSS
    on multiple pages, it's a good idea to use a stylesheet. Then
    you can make
    changes in one place that affects all the pages linked to
    that stylesheet.
    When you click OK, a new box will open where you can define
    your CSS.
    Select "background" from the sidebar, and the fill in areas
    are pretty self
    explanatory.
    I hope that helps.
    Take care,
    Tim
    "Jimtheman2000" <[email protected]> wrote in
    message
    news:fo84t1$je9$[email protected]..
    > Im trying to set up an about me page like that of
    myspace.com i know that
    > in myspace you can set the background image center non
    repeat can this be
    > done as will with dreamweaver?

  • How to properly create a non-repeat report block?

    Hi everyone,
    I am trying to create a front page for my report. In the report data mode I have a query only return one record, so why that query in the data model showed as a group? <It has the query name - Q_1 on the top, and a group box at the bottom named G_xxxx.>
    Second question is why i use the report block wizard to create the frontpage, the wizard forced me to select a group, otherwise it give warning/error message. I only want to select the client name and his address and no need to repeat <so the frame should use the non-repeatable frame right?>.
    At the moment, I have two queries in the data model, first one is the "select" query which will only return one record for the report's front page, second query is a matrix (cross product) query for the main contents of my report. Both query has no link.
    This is my first Oracle report so any suggestions are the most welcoming.
    Thank you
    Bryan
    Edited by: Bryanevil on Apr 8, 2009 8:19 AM
    Edited by: Bryanevil on Apr 8, 2009 8:26 AM

    Thanks DC
    Thats what I was thinking too. Is this the only way to create a non-repeatable frame; no wizard can be use for create non-repeatable report block? Why I am asking this is because I am lazy, dont want to add all the fields and labels one by one to the frame.
    Secondly, in the data model, is there any way to create a query which the data model will not recognise it as a group query but a single record query?
    Regards
    Bryan

  • How to genrate non-repeating random numbers

    Hi everyone, i'm trying to write a for loop that genrate a
    list of non-repeating random index number for an array list but i
    can't seem to get the random numbers non-repeat. I'm a newbie in
    Flex 2 so it would be great if anyone could show me what seems to
    be the problem in this code:
    Thank you very much.
    Richie
    for (var j:Number = 0; j < tempArray.length; j++)
    var randomNum:Number =
    Math.round(Math.random()*tempArray.length);
    if (j - 1 >= 0)
    while (randomNum == randomIndex[j-1].index)
    randomNum = Math.round(Math.random()*tempArray.length);
    //Push the random number in an array
    randomIndex.push({index: randomNum});
    Alert.show(randomNum.toString());
    }

    Dont' worry about it guys, i already got it thanks!

  • How do you print a repeating address label, a return address label, from address book

    How do you print a repeating address, like for a return address label.

    Apple - any movement on this? Everyone needs this feature from Contacts, and it seems very silly to make us download another application. How do we create a feature request?

  • I have "ghost" events on my printed calendars repeating daily after the original event. How can I delete these as they only appear on the printed calendars and not on the on screen version?

    I have "ghost" events on my printed calendars repeating daily after the original event. How can I delete these as they only appear on the printed calendars and not on the on screen version?

    I had a similar situation.  My credit card bill shows a charge on Sept 8 and Sept 9, both for $55.99.  I called Apple but they said that I was the victim of identity theft so I cancelled my credit card.  They have not refunded my money.

  • Selecting Non repeatable random records

    HI all,
     I have 20 records in table. I want to get a random single  record from that table.And the main thing is
    if i having 20 records 1st time i'm getting a random record.the upcoming execution result that does not show previous random record .
    That is out of 20 records ,each time i want to select record that does not occur previously.so at 20 executions i have 20 result with non-repeatable.
    If i am confusing you,sorry for this.....pls help me to get a suffled record at each time
    note: i'm used NEWID() that gives random records but it occurs previously some time

    I cannot reproduce this :-)
    with
    [10] as (select 0 as c union all select 0),
    [11] as (select 0 as c from [10] as a, [10] as b),
    [12] as (select 0 as c from [11] as a, [11] as b),
    [13] as (select 0 as c from [12] as a, [12] as b),
    nums as (select top(20) row_number() over(order by c) as n from [13]),
    choice as (select top(1) n from nums order by checksum(newid()))
    select * from choice order by n 
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Printing Non Modal External Window - print out additional blank page

    Hi All,
    I am printing out a content of a web dynpro view as a non modal external window with the browser print functionality.
    Even if the content of the web dynpro view is not more than the half of a page the browser print functionality prints 2 pages. The second page is a blank page.
    I tried to change the external window size in web dynpro, but it is still printing 2 pages.
    How can I set / configure the browser print functionality, so it prints only the page that contains the web dynpro view content?
    Thanks,
    Yasar

    Hi,
    I'm guessing the concurrent program is outputting text (character mode) as opposed to PDF?
    This could be a number of reasons:
    1. Printer driver issue, e.g. the number of lines printed on the page is more than is defined for the printer driver: Try reducing the "Rows" on the current program definition
    2. Printer PRT issue, extra page break could be being inserted.
    3. The "box" in the report definition containing the address could be being expanding due to the extra address line, but not enough space so it forces a new page to be printed.
    Gareth
    Blog: http://garethroberts.blogspot.com
    Web: http://www.virtuate.com

  • Printing "non-words"

    my canon printer iP6000D has begun to print my spreadsheet words as what i would describe as "non-words" The numbers in the spreadsheet print as typed but the english words do not print as typed. For example: CELLS is printed out as & LLS. Another word, ST. JO comes out as S3. JO and so forth. The other documents that are not spreadsheets, i.e., that are word processing documents come out correctly.

    I just meant that you could create a new user account in the Accounts pane of System Preferences for testing purposes. You create the account, log in as that user and see if the problem persists. If not, you know the problem is something specific to your user account. If it persists, it must be system-wide. This helps target trouble-shooting appropriately.
    - cfr

  • How to print non XFA pdf from LC

    Hi,
    I am aware that this is not neccessary a LC Output question,but could not find a better place for it
    I cannot find a service in LC ES2 that can print a normal (non XFA) pdf to a printer – can this be true?? If it is an XFA form, we can use the generatePrintedOutput and create PCL or PS depending on the target printer. But how would you do it with a flat pdf with watermark or a word document converted to pdf on LC??
    Must be alot of clever people having solved this issue outthere, bring it on
    Thanks,
    Thomas Groenbaek
    Jyske Bank, Denmark

    I know, but I do not want to send the pdf directly - want to convert it to ps or pcl.
    If the pdf is a XFA i can use the generatePrintedOutput and works fine. But in this case it is a "flat"/non xfa and I want LC to be able to convert it to a printer language format to print it. How is this done in the best way?
    I see a toPS from convertToPdf service, is that handy?
    Is xdc files the way?
    good input and best practices is appreciated
    Thanks,
    Thomas

Maybe you are looking for

  • Airport internet connection problems in OS X but not in XP or iBook

    I have an iBook and an iMac, and the iMac has Leopard and XP on it. When in Leopard, most of the time, the internet connection is extremely slow and can never load a full page in Safari, always quitting halfway or the connection drops completely. Whe

  • How to extract Cognos Data into Business Objects?

    Hi All, I would like to know whether anyway to pull Cognos data into Business Objects? 1. Pull data thru Universe from Cognos Cubes? 2. Pull data using Crystal reports from Cognos Cubes? 3. Or any otehr method of pulling data from Cognos Cubes? If no

  • Uix form navigation links

    At the bottom of a uix form, the global buttons and tabs are replicated as navigation links. How can i remove these navigation links thanks darryl

  • Important: Upgrade safe Controller extension

    Hi i had to actually changed my VO query to include a new attribute, for which i extended the view object . I also needed to pass argument to the query thru "setWhereClauseParam". For this i am required to change the code in controller also. My query

  • HT1711 Re: I Tunes Gift Card

    I scrathced off the back of my card and some of the numbers are missing.. How to I redeem it.. april