Go Back   Rhinocerus > Newsgroup > Newsgroup comp.language.c++



Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 02-04-2010, 08:09 AM
dushkin
Guest
 
Posts: n/a
Default multiset unique values count

Hi
I wish someone can give a tip on this one..
http://groups.google.co.il/group/com...060bace91a1830
Thanks!
Reply With Quote
Alt Today
Advertising
Google Adsense
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 02-09-2010, 01:59 AM
tonydee
Guest
 
Posts: n/a
Default Re: multiset unique values count

On Feb 4, 5:09*pm, dushkin <talt...@gmail.com> wrote:
> Is it possible to know (without iterating ofcourse) how many
> unique keys are in a multiset?
> I know that a set has unique values, but I would prefer
> using multiset in my solution if I have the unique keys
> counting solution.
>
> Example:
>
> Given a multiset with values: {1,1,2,4,5,4,3,1} - The unique
> counting will give me 5 for {1,2,3,4,5} keys.


> A indirect solution may be adding the multiset items to a
> set and then get the set size..
> But I wonder if there is a direct way of getting the unique
> items number


STL's multisets do not have any special support for this, i.e. they
don't spend time / use extra memory to track the unique keys while the
values are being inserted. Therefore, you must either proactively
maintain your own count while inserting and erasing from the multiset
(e.g. insert: check if the multiset includes the key, add 1 to
unique_keys counter if not). Otherwise, you will need to step through
the container to count unique keys... using upper_bound() will skip to
the next key, which just might be faster than a simple iteration, but
could also be slower (may depend on average number of times a key
repeats).

Cheers,
Tony
Reply With Quote
 
Reply

Popular Tags in the Forum
count, multiset, unique, values

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Count Challenge (was Counting Unique ID) Jack Hamilton Newsgroup comp.soft-sys.sas 0 10-10-2009 09:07 PM
Re: count of distinct values for all field in database Mary Newsgroup comp.soft-sys.sas 0 12-10-2008 04:53 PM
Re: get count of unique values for all variables in a dataset David L Cassell Newsgroup comp.soft-sys.sas 0 10-10-2005 07:53 PM
Re: Using Hash Object to count distinct number of values in an Paul M. Dorfman Newsgroup comp.soft-sys.sas 0 04-30-2005 07:04 PM
Re: Global Count! Sigurd Hermansen Newsgroup comp.soft-sys.sas 0 11-04-2004 04:48 PM



Language 1 | C | C++ | Php | Python | Lisp | Perl | Ruby | Java | Pascal | Basic | Language 2 | Databases | Oracle | Mysql | Access | Drupal
All times are GMT. The time now is 04:04 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.