Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Generics and Linked Lists

Reply
Thread Tools

Generics and Linked Lists

 
 
GreenMountainBoy
Guest
Posts: n/a
 
      02-19-2007
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

 
Reply With Quote
 
 
 
 
Boaz.Jan@gmail.com
Guest
Posts: n/a
 
      02-19-2007
On Feb 19, 6:56 am, "GreenMountainBoy" <(E-Mail Removed)>
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

 
Reply With Quote
 
 
 
 
sdemchenko@gmail.com
Guest
Posts: n/a
 
      02-19-2007
Does not java.util.LinkedHashSet do what you need?

 
Reply With Quote
 
GreenMountainBoy
Guest
Posts: n/a
 
      02-19-2007
On Feb 19, 7:30 am, "(E-Mail Removed)" <(E-Mail Removed)> wrote:
> On Feb 19, 6:56 am, "GreenMountainBoy" <(E-Mail Removed)>
> 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

 
Reply With Quote
 
Mark Rafn
Guest
Posts: n/a
 
      02-19-2007
GreenMountainBoy <(E-Mail Removed)> 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.velocityreviews.com/forums/(E-Mail Removed) <http://www.dagon.net/>
 
Reply With Quote
 
mickey
Guest
Posts: n/a
 
      02-19-2007
On Feb 19, 9:56 am, "GreenMountainBoy" <(E-Mail Removed)>
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: (E-Mail Removed)

 
Reply With Quote
 
GreenMountainBoy
Guest
Posts: n/a
 
      02-19-2007
On Feb 19, 3:29 pm, "mickey" <(E-Mail Removed)> wrote:
> On Feb 19, 9:56 am, "GreenMountainBoy" <(E-Mail Removed)>
> 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: (E-Mail Removed)


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.

 
Reply With Quote
 
Mark Rafn
Guest
Posts: n/a
 
      02-19-2007
GreenMountainBoy <(E-Mail Removed)> 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 (E-Mail Removed) <http://www.dagon.net/>
 
Reply With Quote
 
GreenMountainBoy
Guest
Posts: n/a
 
      02-21-2007
On Feb 19, 5:07 pm, (E-Mail Removed) (Mark Rafn) wrote:
> GreenMountainBoy <(E-Mail Removed)> 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 (E-Mail Removed) <http://www.dagon.net/>


thanks for help - i think i have it figured out!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Airplane Program with Linked Lists. The linked list portion is veryconfusing to me. jawdoc C++ 9 03-10-2008 03:38 AM
List of lists of lists of lists... =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==?= Python 5 05-15-2006 11:47 AM
Can't convert a generics list of objects into a generics list ofinterfaces Juergen Berchtel Java 1 05-20-2005 02:07 PM
Generating a char* from a linked list of linked lists Chris Ritchey C++ 7 07-10-2003 10:12 PM
Generating a char* from a linked list of linked lists Chris Ritchey C Programming 7 07-10-2003 10:12 PM



Advertisments