This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Making Sure to Skip Duplicates When Populating LinkedList  RSS feed

 
Ranch Hand
Posts: 1867
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I make sure that the list 'rnameplates' does not get any duplicate values added to it?


 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in your condition you check only emply record


but there are not places where you can check instance into the list like something here:


More you can see here: http://stackoverflow.com/questions/30002483/arraylist-check-if-data-already-exists
 
Steve Dyke
Ranch Hand
Posts: 1867
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vasyl Lyashkevych wrote:

but there are not places where you can check instance into the list like something here:



That is what I thought I needed to do but I could not get following to work. Trying to iterate over the list as it is being built.

 
Marshal
Posts: 60065
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use a List. Lists are designed to support duplicates, so you want a data structure that doesn't support duplicates. If you go through the Java™ Tutorials, you shou‍ld find a different sort of collection which both rejects duplicates and maintains insertion order. I regard it as a hybrid collection because it has features of two different types of collection.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!