My concern is adding string to array of string, but I wanted to make sure that this string is unique before inserting into the array. I searched and found many approaches for this but my concern is to make faster rather than checking all array elements for duplicate before adding the string, so I decided to do the following:
- Get the string (URL from URL Mining Project, that may return thousands of URLs and may be duplicated in sometimes, as cross referenced).
- Get the ASCII for all characters in the URL and add them up multiplied by the index of the char (this is to make unique identifier for each URL).
- This value in point 2 will be the index in the array to insert this URL in.
- The Problem now, this array should be dynamic (How to resize it depending on number of URLS I'm mining?).
- The array will be porous (means array with many nulls), is there any efficient way to get the cells that have values only?
- Below code is used to get the position for unique string.
int index = 1;
int position = 0;
string s = Console.ReadLine();
byte[] ASCIIValues = Encoding.ASCII.GetBytes(s);
foreach(byte b in ASCIIValues)
{
position += b * index;
index++;
Console.WriteLine(b);
}
List<T>)? You may always check iflist.Contains(value). Or.Add(value).HashSet<T>