Load txt file (CSV) into Generic Dictionary Javascript

currentlyl I’m loading a csv into an array. I want to be able to search it for a string so I think I should use a generic dictionary as it will be faster - the array is quite large.

My current code is:

var wordCSV : TextAsset;

function Start () 
{
	//Load Dictionary
	var wordList = wordCSV.text.Split(";"[0]);
}

function FindWord(word : String)
{
	for(int i = 0; i < array.Length; i++)
	{
	  if(array*.name == word)*
  • {*
  •     print("I am element number " + i );* 
    
  • }*
  • }*
    }
    How can I do the same with a Generic Dictionary?

You wouldn’t use a Dictionary, since that’s for key/value pairs. If all you want to do is tell if a collection contains a word, then you’d use a HashSet.

var wordSet = new HashSet.< String >(wordList);
if (wordSet.Contains("cat")) {
    Debug.Log ("Yep.");
}