471,326 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,326 software developers and data experts.

Array duplicates

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

Feb 17 '06 #1
1 1729
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.
--
"Maya" <kf****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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

Feb 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Dan | last post: by
11 posts views Thread by cdg | last post: by
14 posts views Thread by ak | last post: by
4 posts views Thread by Mokita | last post: by
3 posts views Thread by powerej | last post: by
5 posts views Thread by fluk | last post: by
Thekid
3 posts views Thread by Thekid | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.