Array duplicates

  • Thread starter Thread starter Maya
  • Start date Start date
M

Maya

Hello,

In the array abc:

abc[0] = "john"
abc[1] = "jack"
abc[2] = "john"
abc[3] = "peter"

Is there an easy way to check for "john" existence before inserting
abc[2]?

If not, any idea how to remove either duplicates? that is abc[0] or
abc[2] in the above array?

Thanks in advance.

Maya
 
Why use an array? Use a hashtable. Then you can look up the value before
you insert it and only insert it if it is not already there.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 

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

Back
Top