Generics and Linked Lists

Discussion in 'Java' started by GreenMountainBoy, Feb 19, 2007.

  1. sorry for xcrosslist - just did it once.

    Generics Linked List -

    I am trying to find an example or partial example of how you could
    write a program that takes only one first name per node, and that you
    can later search for one name. No duplicates.




    Thanks for you thoughtful help. It is much appreciate.

    GreenMountainBoy
     
    GreenMountainBoy, Feb 19, 2007
    #1
    1. Advertising

  2. GreenMountainBoy

    Guest

    On Feb 19, 6:56 am, "GreenMountainBoy" <>
    wrote:
    > sorry for xcrosslist - just did it once.
    >
    > Generics Linked List -
    >
    > I am trying to find an example or partial example of how you could
    > write a program that takes only one first name per node, and that you
    > can later search for one name. No duplicates.
    >
    > Thanks for you thoughtful help. It is much appreciate.
    >
    > GreenMountainBoy


    its kindof vauge... can you explain what you want execly?
    first name per node?
    search for one name no duplicates? you want first name to act like a
    uniqe key? your list node are String firstName?
    if you want no duplicates and your nodes only contain the firstname i
    would suggest using h hashmap
    the key will be the firstname string value and the value of the node
    wll be the "Entity" which contains the first name
    with hashmap you cant have duplicate keys... but its not a linked list
    as you mentioned but it is genereic

    if you want to use a simle linked list you may manage the add method
    so it wont add any object that conatins the same first name (implement
    Comparable for you node so your code will be clean)
    and then you can search for a first name simply by iterating the list
    (if thats what you wanted)

    for more exact help i will need more info about what you are trying to
    do
     
    , Feb 19, 2007
    #2
    1. Advertising

  3. GreenMountainBoy

    Guest

    Does not java.util.LinkedHashSet do what you need?
     
    , Feb 19, 2007
    #3
  4. On Feb 19, 7:30 am, "" <> wrote:
    > On Feb 19, 6:56 am, "GreenMountainBoy" <>
    > wrote:
    >
    > > sorry for xcrosslist - just did it once.

    >
    > > Generics Linked List -

    >
    > > I am trying to find an example or partial example of how you could
    > > write a program that takes only one first name per node, and that you
    > > can later search for one name. No duplicates.

    >
    > > Thanks for you thoughtful help. It is much appreciate.

    >
    > > GreenMountainBoy

    >
    > its kindof vauge... can you explain what you want execly?
    > first name per node?
    > search for one name no duplicates? you want first name to act like a
    > uniqe key? your list node are String firstName?
    > if you want no duplicates and your nodes only contain the firstname i
    > would suggest using h hashmap
    > the key will be the firstname string value and the value of the node
    > wll be the "Entity" which contains the first name
    > with hashmap you cant have duplicate keys... but its not a linked list
    > as you mentioned but it is genereic
    >
    > if you want to use a simle linked list you may manage the add method
    > so it wont add any object that conatins the same first name (implement
    > Comparable for you node so your code will be clean)
    > and then you can search for a first name simply by iterating the list
    > (if thats what you wanted)
    >
    > for more exact help i will need more info about what you are trying to
    > do




    I am trying to implement a linkedList program using Generics -
    LinkedList with an iterator. The only data in each node is a single
    string. I need to be able to add a string to a new node, and also have
    a separate snippet which allows for a search of the linked list (using
    Generics LinkedList structure) for a match on the string stored in one
    of the nodes - if no match is found, return "NO MATCH" -
    this must be done using the LinkedList from the Generics utility
    class.

    Please see if this helps and give me a clue as to how to get started.

    Thank you,

    GreenMountainBoy
     
    GreenMountainBoy, Feb 19, 2007
    #4
  5. GreenMountainBoy

    Mark Rafn Guest

    GreenMountainBoy <> wrote:
    >I am trying to implement a linkedList program using Generics -
    >LinkedList with an iterator.


    Why not use java.util.LinkedList<String>? Or if this is homework, why not
    look at the source for java.util.LinkedList to learn (steal) from?

    >Please see if this helps and give me a clue as to how to get started.


    Start by telling us what you've tried so far, and ask very specific questions
    about where you're stuck. This group sucks at writing your homework for you,
    on purpose.
    --
    Mark Rafn <http://www.dagon.net/>
     
    Mark Rafn, Feb 19, 2007
    #5
  6. GreenMountainBoy

    mickey Guest

    On Feb 19, 9:56 am, "GreenMountainBoy" <>
    wrote:
    > sorry for xcrosslist - just did it once.
    >
    > Generics Linked List -
    >
    > I am trying to find an example or partial example of how you could
    > write a program that takes only one first name per node, and that you
    > can later search for one name. No duplicates.
    >
    > Thanks for you thoughtful help. It is much appreciate.
    >
    > GreenMountainBoy




    hi... GEnerics Linked List seem to be tough to me at the very
    beginning ....still i have no deeper understanding of the how to make
    program that takes only one first name per node
    CAN u plzz suggest me from where to refer this topic ...any book or
    any tutorial that can build idea regarding linked list and other
    topics ..
    plzz reply me regerding this///
    mailto:
     
    mickey, Feb 19, 2007
    #6
  7. On Feb 19, 3:29 pm, "mickey" <> wrote:
    > On Feb 19, 9:56 am, "GreenMountainBoy" <>
    > wrote:
    >
    > > sorry for xcrosslist - just did it once.

    >
    > > Generics Linked List -

    >
    > > I am trying to find an example or partial example of how you could
    > > write a program that takes only one first name per node, and that you
    > > can later search for one name. No duplicates.

    >
    > > Thanks for you thoughtful help. It is much appreciate.

    >
    > > GreenMountainBoy

    >
    > hi... GEnerics Linked List seem to be tough to me at the very
    > beginning ....still i have no deeper understanding of the how to make
    > program that takes only one first name per node
    > CAN u plzz suggest me from where to refer this topic ...any book or
    > any tutorial that can build idea regarding linked list and other
    > topics ..
    > plzz reply me regerding this///
    > mailto:


    I have the code working - but the iterator over the list bombs out
    every time
    I do iterator.next().equals(strng) - this is where I am looking for
    the name i put in the LinkedList of generic type.

    Thanks, man.
     
    GreenMountainBoy, Feb 19, 2007
    #7
  8. GreenMountainBoy

    Mark Rafn Guest

    GreenMountainBoy <> wrote:
    >I have the code working - but the iterator over the list bombs out
    >every time I do iterator.next().equals(strng) - this is where I am looking
    >for the name i put in the LinkedList of generic type.


    Show us some code, and tell us what exception you're getting. "I do something
    and it doesn't work" doesn't give much room to help.
    --
    Mark Rafn <http://www.dagon.net/>
     
    Mark Rafn, Feb 19, 2007
    #8
  9. On Feb 19, 5:07 pm, (Mark Rafn) wrote:
    > GreenMountainBoy <> wrote:
    > >I have the code working - but the iterator over thelistbombs out
    > >every time I do iterator.next().equals(strng) - this is where I am looking
    > >for the name i put in the LinkedList of generic type.

    >
    > Show us some code, and tell us what exception you're getting. "I do something
    > and it doesn't work" doesn't give much room to help.
    > --
    > Mark Rafn <http://www.dagon.net/>


    thanks for help - i think i have it figured out!
     
    GreenMountainBoy, Feb 21, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Juergen Berchtel
    Replies:
    1
    Views:
    6,009
    John C. Bollinger
    May 20, 2005
  2. Chris Ritchey
    Replies:
    7
    Views:
    484
    emerth
    Jul 10, 2003
  3. Chris Ritchey

    Generating a char* from a linked list of linked lists

    Chris Ritchey, Jul 9, 2003, in forum: C Programming
    Replies:
    7
    Views:
    472
    emerth
    Jul 10, 2003
  4. =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==

    List of lists of lists of lists...

    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==, May 8, 2006, in forum: Python
    Replies:
    5
    Views:
    410
    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==
    May 15, 2006
  5. jawdoc
    Replies:
    9
    Views:
    760
    Chris Thomasson
    Mar 10, 2008
Loading...

Share This Page