Generics and Linked Lists

G

GreenMountainBoy

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
 
B

Boaz.Jan

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
 
G

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
 
M

Mark Rafn

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

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.
 
M

mickey

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 address removed)
 
G

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 address 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.
 
M

Mark Rafn

GreenMountainBoy said:
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.
 
G

GreenMountainBoy

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.

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top