A
Amit
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 this purpose.
However, I am also interested in having no duplicacy in elements of
the vector. So I do not want to have any integer repeated more than
once in the list.
One very naive approach could be to compare the new integer being
added to every element of the list already present. Can I do any
better, by using sort() and unique() methods(in conjunction) in the
list? I am not aware of any such methods for a vector.. Any suggestions
which one might be better in terms of efficiency?
thanks,
--a.
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 this purpose.
However, I am also interested in having no duplicacy in elements of
the vector. So I do not want to have any integer repeated more than
once in the list.
One very naive approach could be to compare the new integer being
added to every element of the list already present. Can I do any
better, by using sort() and unique() methods(in conjunction) in the
list? I am not aware of any such methods for a vector.. Any suggestions
which one might be better in terms of efficiency?
thanks,
--a.