473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Removing Duplicate Entries in a vector

Hello All,
I am currently trying to do the following:
1) I have a vector<string> which has 'n' number of elements (n is quite large order of 100,000)
2) Some of the elements in this vector are repeated

Hence i need to get a resultant vector which will have only single elements (i.e. no repitition).
What would a really fast scheme to achieve this.

Thanks as always !!
Sep 4 '07 #1
2 2126
gpraghuram
1,275 Expert 1GB
Hello All,
I am currently trying to do the following:
1) I have a vector<string> which has 'n' number of elements (n is quite large order of 100,000)
2) Some of the elements in this vector are repeated

Hence i need to get a resultant vector which will have only single elements (i.e. no repitition).
What would a really fast scheme to achieve this.

Thanks as always !!
If u have around 1,00,000 elements then vector is not the right one to use.
Use deque .
Then for getting the unique elements, idea what i have is push the elements to a set which will maintain only unique elemnts and after that you can take the elemnts from it and store it to a deque
Raghuram
Sep 4 '07 #2
If u have around 1,00,000 elements then vector is not the right one to use.
Use deque .
Then for getting the unique elements, idea what i have is push the elements to a set which will maintain only unique elemnts and after that you can take the elemnts from it and store it to a deque
Raghuram

Hello....
Thanks a lot. I managed to do it using only sets.
I was reading the input from a file which I put in a set now (which previously in a vector).
/ Sid
Sep 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: andreas.maurer1971 | last post by:
Hi all, since a few years I use the following statement to find duplicate entries in a table: SELECT t1.id, t2.id,... FROM table AS t1 INNER JOIN table AS t2 ON t1.field = t2.field WHERE...
3
by: Amit | last post by:
Hi, I have a list of integers. At each iteration, I remove some element from it and then insert new elements in it. The order of elements is not important. So I guess I could use a vector also for...
3
by: Rad | last post by:
I have a table . It has a nullable column called AccountNumber, which is of varchar type. The AccountNumber is alpha-numeric. I want to take data from this table and process it for my application....
4
by: sri2097 | last post by:
Hi all, I'm storing number of dictionary values into a file using the 'cPickle' module and then am retrieving it. The following is the code for it - # Code for storing the values in the file...
1
by: Allerdyce.John | last post by:
I have a vector of Pair of int: typedef pair<int, int> MyPair; typedef vector <MyPair > MyVector I would like to remove entries if their first are equal, or if their value is swap ( first of...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
1
by: gaikokujinkyofusho | last post by:
Hi, I have been enjoying being able to subscribe to RSS (http://kinja.com/user/thedigestibleaggie) for awhile and have come up with a fairly nice list of feeds but I have run into an annoying...
12
by: joestevens232 | last post by:
Hello Im having problems figuring out how to remove the duplicate entries in an array...Write a program that accepts a sequence of integers (some of which may repeat) as input into an array. Write...
4
by: ejack | last post by:
int total = static_cast<int>(vComp.size()) - 1; int tTotalUnits = 0; float tTotalCostJob = 0; int i = 0; int j = 0; int counter = 0; bool foundFlag; vector<string> vItems;...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.