473,657 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

searching an array list

Hey

I need to search an array list to remove duplicate Data
The list is populated by a search function that enters in a name if the it is told too

This causes duplicate names to be entered into the array, the search function is not changable

e.

the array list has 5 values "jonny", I need to remove all the values but the 1st. The array can have several differnet copies of one name

Thanks

/Jonny
Nov 15 '05 #1
4 4468
Hi Jonny,
Check out the forum answers in this link
http://www.experts-exchange.com/Prog..._20824139.html
I think it will help you

--
Rami Saad
Microsoft GTSC Developer support for Middle East
"jonny" <jo************ *****@hotmail.c om> wrote in message
news:78******** *************** ***********@mic rosoft.com...
Hey,

I need to search an array list to remove duplicate Data.
The list is populated by a search function that enters in a name if the it is told too.
This causes duplicate names to be entered into the array, the search function is not changable.
e.g

the array list has 5 values "jonny", I need to remove all the values but the 1st. The array can have several differnet copies of one name.
Thanks,

/Jonny

Nov 15 '05 #2
On Wed, 25 Feb 2004 04:41:05 -0800, jonny wrote:
Hey,

I need to search an array list to remove duplicate Data.
The list is populated by a search function that enters in a name if the it is told too.

This causes duplicate names to be entered into the array, the search function is not changable.

e.g

the array list has 5 values "jonny", I need to remove all the values but the 1st. The array can have several differnet copies of one name.

Thanks,

/Jonny


One solution is to first sort the array, then loop through it. If an
items value is the same as the previous item, delete it.

HTH,
Tim
--
Tim Smelser - MVP Visual C#
To email me, make the snot hot.
Nov 15 '05 #3
jonny wrote:
Hey,

I need to search an array list to remove duplicate Data.
The list is populated by a search function that enters in a name if the it is told too.

This causes duplicate names to be entered into the array, the search function is not changable.

e.g

the array list has 5 values "jonny", I need to remove all the values but the 1st. The array can have several differnet copies of one name.


Try this:

// filledArrayList - your ArrayList
int index;

for(int i=0; i<(filledArrayL ist.Count-1); i++) {
index=filledArr ayList.IndexOf( filledArrayList[i], i+1);
while( index>i ) {
filledArrayList .Remove(index);
if( i<(filledArrayL ist.Count-1) ) {
index=filledArr ayList.IndexOf( filledArrayList[i], i+1);
}
else {
index=-1;
}
}
}

Regards

Marcin
Nov 15 '05 #4
maybe you should use Hashtable class instead of an ArrayList?

"jonny" <jo************ *****@hotmail.c om> wrote in message
news:78******** *************** ***********@mic rosoft.com...
Hey,

I need to search an array list to remove duplicate Data.
The list is populated by a search function that enters in a name if the it is told too.
This causes duplicate names to be entered into the array, the search function is not changable.
e.g

the array list has 5 values "jonny", I need to remove all the values but the 1st. The array can have several differnet copies of one name.
Thanks,

/Jonny

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2542
by: Daniel Pryde | last post by:
Hi everyone. I was wondering if anyone might be able to help me out here. I'm currently looking to find the quickest way to find a best fit match in a large array. My problem is that I have an array of, say, 600*400, which contains a value at each point, and I need to find the value in that array which is closest to the input value. It's basically some euclidean distances that I've calculated, and I need to be able to find the best matches...
6
5485
by: Jonathan | last post by:
I am hoping that someone more experienced than myself can point me towards what might be the fastest data lookup method to use for storing ip addresses. My situation is that I will need to maintain a list of perhaps 50 ip addresses to be used in a packet sniffing application. For each packet that goes through the application (which will be monitoring all traffic through a switch), I need to see if an entry for the source ip of that packet...
5
5393
by: Alan Mackenzie | last post by:
I've recently moved onto a C++ project with a large number of directories (several hundred) containing an even larger number of C++ source files. There are vastly more ways in C++ to obfuscate a program than there are in C, and it seems somebody laid a bet on the original development team to prove that this is the case. ;-( Unfortunately, I have no contact with the original programmers, who live and work on a different continent. In...
33
2479
by: Geoff Jones | last post by:
Hiya I have a DataTable containing thousands of records. Each record has a primary key field called "ID" and another field called "PRODUCT" I want to retrieve the rows that satisy the following criteria: I have a list of about 100 numbers which correspond to the ID field and also another 40 say numbers corresponding to the numbers in the PRODUCT field. I want to show the rows that correspond to both these criteria.
2
4633
by: Larry | last post by:
I have a Byte Array Dim A1() as byte = {1,2,3,4,9,9,9,11,12,13,14,9,9,9} I want to find the location of the first occurance of the byte sequence {9,9,9}. Is there a built in Framework class that will do this easily? I've tried messing with Array.IndexOf but can't seem to get it to indicate where the byte sequnce starts.
3
3731
by: inkexit | last post by:
I need help figuring out what is wrong with my code. I posted here a few weeks ago with some code about creating self similar melodies in music. The coding style I'm being taught is apparently a lot different from what the pros around here use. I really need help with debugging some program errors more than anything, even though my coding style might not be perfect. Anyway here is my code. About the only things that work right are...
5
1496
by: Jerim79 | last post by:
I am trying to create a search system for an existing database. Because of the way the database is setup, I need to traverse three different tables, gathering information: 1) Go into table1 and lookup show_id by show name. (For instance, let's say I am looking for the Mickey Mouse show. I look it up and find that it's show_id is 6) 2) Go into table2 and lookup all attendee_ids for show_id 6. (For instance, I lookup show_id 6 and find...
5
3179
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The search algorithms that can be used are Linear Search and Binary Search. The sorting algorithms are bubble, selection and Insertion sort. First, the user is asked whether he/she wants to perform a search option, a sort operation, or exit the program. If...
3
1908
by: jac130 | last post by:
the program runs, and user is prompted via inputbox to enter an integer-this is the size of the array, then the user fills the array with that many values...but as the user enters the values, i need to check and make sure that none of hte values have already been entered in the array, if it has..then there must be a message telling user to enter a new value. EX: user prompted to enter an integer e.g.-2, then user is prompted to enter values...
0
8425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8522
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.