I write a code, but I need it to work faster, not in O(n).
public T GetElementAt(int index)
{
return hashSet.ElementAt(index);
}
and another one
public T GetElementAt(int index)
{
var enumerator = hashset.GetEnumerator();
for (int i = 0; i < index; i++)
{
enumerator.MoveNext();
}
return enumerator.Current;
}
Please, help me, I have no idea how to do this.
P.S. Sorry for my bad English.