counting unique items in an unsorted array 
Author Message
 counting unique items in an unsorted array

Does STL provide an algorithm to count the number of unique items in an
unsorted array? In our application this is required because we have multiple
dimensions and time contstraints do not permit resorting the array.

Thanks, Conan



Sun, 13 Oct 2002 03:00:00 GMT  
 counting unique items in an unsorted array
I think you need to seriously reconsider the container you're storing the
data in.  If you need fast lookup, then vector<> is not what you should use.
Without more details on what you're storing, its hard to make more specific
recommendations.

If you never remove items, then you could keep a set<> and insert into the
set at the same time you insert into the vector<>.  Then you just use
set<>::size().

HTH

DanL

Quote:

>Does STL provide an algorithm to count the number of unique items in an
>unsorted array? In our application this is required because we have
multiple
>dimensions and time contstraints do not permit resorting the array.

>Thanks, Conan



Sun, 13 Oct 2002 03:00:00 GMT  
 counting unique items in an unsorted array
Thanks,

I wrote an algorithm to do this. We have mulit-dimension arrays in memory. I
want to be able to get the unique keys from any one column. If one column is
sorted, the others are not. The algorithm is kind of like remove duplicates,
it returns both a count of unique items or an array of unique items.

Conan



Quote:
> I think you need to seriously reconsider the container you're storing the
> data in.  If you need fast lookup, then vector<> is not what you should
use.
> Without more details on what you're storing, its hard to make more
specific
> recommendations.

> If you never remove items, then you could keep a set<> and insert into the
> set at the same time you insert into the vector<>.  Then you just use
> set<>::size().

> HTH

> DanL


> >Does STL provide an algorithm to count the number of unique items in an
> >unsorted array? In our application this is required because we have
> multiple
> >dimensions and time contstraints do not permit resorting the array.

> >Thanks, Conan



Mon, 14 Oct 2002 03:00:00 GMT  
 counting unique items in an unsorted array


Quote:
>Thanks,

>I wrote an algorithm to do this. We have mulit-dimension arrays in memory. I
>want to be able to get the unique keys from any one column. If one column is
>sorted, the others are not. The algorithm is kind of like remove duplicates,
>it returns both a count of unique items or an array of unique items.

Sounds a bit like std::unique_copy to me. Check it out.

[SNIP]



Tue, 15 Oct 2002 03:00:00 GMT  
 counting unique items in an unsorted array
std::unique_copy looks like a fit.

Thanks,
Conan


Quote:


> >Thanks,

> >I wrote an algorithm to do this. We have mulit-dimension arrays in
memory. I
> >want to be able to get the unique keys from any one column. If one column
is
> >sorted, the others are not. The algorithm is kind of like remove
duplicates,
> >it returns both a count of unique items or an array of unique items.

> Sounds a bit like std::unique_copy to me. Check it out.

> [SNIP]



Tue, 15 Oct 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Counting items in a struct array

2. Counting items in a struct array

3. Beginer - CListBox UnSorted items ?

4. how can i build a binary tree from an unsorted array

5. Counting only unique lines (was Programmer Productivity)

6. Counting array char with another array

7. cc: of SortList w/non-unique items

8. POSITION variable of CLIST Item unique?

9. Create a Unique ID for Each Item

10. Windows Forms DataGrid Item Count

11. Item and Count in a COM object

12. Item count limit to CListCtrl?

 

 
Powered by phpBB® Forum Software