Creating an array of unique elements
sybrandy
sybrandy at gmail.com
Mon Dec 27 05:12:42 PST 2010
I've done something like this before using associative arrays. I would
rely on the fact that the keys have to be unique to produce my unique
array. So, in this case, any value you want to store you would save
like this:
array[value] = 1;
Regardless of whether or not the value already exists, this will work
and ensure uniqueness of the keys. To determine if a value is already
part of the array, you can check for the key like this:
if (value in array)
You can later get the values like this:
values = array.keys;
Not sure if this will do everything you want, but it seems to be cleaner
than having to ensure an array is unique after every insertion.
Casey
More information about the Digitalmars-d-learn
mailing list