Using duplicate data in Dictionary or Collection

E

ExcelMonkey

Is there a way to load data strings (with some duplicates) into a container
and then use some form of .Exists and .Remove (i.e. not an array) to redefine
the container? Note I need the duplicates for calclations purposes.

I have a list of strings. I load them into a container. There are
duplicate strings. I need the duplicates as I am calculating the frequency of
their occurences. I then check the entire list for a sub list of strings
and remove these strings. Becasue I am using duplicate strings I cannot use
a collection or a dictionary as they cannot take duplicate keys. Therefore I
am using an array.

However when it comes time to removing the stings (rows) I don't have the
luxury of using .Exist booleans as I can with a dictionary object. I have to
loop through the entire array to see if the sting exists AND THEN I have find
a way to get rid of all my empty rows in the array. Probably the best way to
do this is to transfer all nonempty data from first arraty into second array
and then back to first arrray. Bit of pain

Any ideas?

Thanks

EM
 
K

krcowen

Is there a way to load data strings (with some duplicates) into a container
and then use some form of .Exists and .Remove (i.e. not an array) to redefine
the container?  Note I need the duplicates for calclations purposes.

I have a list of strings.  I load them into a container.  There are
duplicate strings. I need the duplicates as I am calculating the frequency of
their occurences.  I  then check the entire list for a sub list of strings
and remove these strings.  Becasue I am using duplicate strings I cannot use
a collection or a dictionary as they cannot take duplicate keys.  Therefore I
am using an array.  

However when it comes time to removing the stings (rows) I don't have the
luxury of using .Exist booleans as I can with a dictionary object.  I have to
loop through the entire array to see if the sting exists AND THEN I have find
a way to get rid of all my empty rows in the array.  Probably the best way to
do this is to transfer all nonempty data from first arraty into second array
and then back to first arrray.  Bit of pain

Any ideas?

Thanks

EM

EM

Seems like you could use a class to contain your strings. Then you
could keep a count as duplicates arise. You would have all your
frequence information available and a list of unique strings to check
against for your removal.

Ken
 
E

ExcelMonkey

Right. So I create a class called Thing which is effectviely my strings with
frequency data. Then I create aa class called Things (which is a collection
of Thing). I then add all my indvidual Thing ojbects to Things. Then when it
comes time to get rid of my strings, I am really just removing the invidual
Thing Objects from my Collection Things.

Does that sound right? Or have I created the same issue with the Custom
Collection by not being able to add duplicate "keys" to it?

Thanks

EM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top