arrays - Optimizing .NET function in terms of search index usage -
I have a function that I wrote to search an array for the occurrence of a particular word. This function takes into an array of rows of text and searches for a targeted keyword and gives an array of insights containing the target word. For example if there is an array (each line is a subscript of the array):
Test. Net Application Large brown cat sample application search index optimization search cat for large pink elephant
and the function call is FindLinesInArray (arr, "cat"), then the function will return and array list with two rows:
The search for the big brown cat for the cat
The function is as follows:
function FindLinesInArray (ByRef arr () string, as string As ByVal target) ArrayList dim tone in the form of slow idx As String = "" Dim alist as to attempt to ArrayList = New ArrayList () Idx = 0 arr.Length - 1 if arr (idx) Kostring (). ToLower () Indexoff (target) & lt; & Gt; -1 then temp = arr (idx). Ostring (). ToLower (). Trim () alist.Add (temp) end if try the next catch up exception end in the form of MsgBox (ex.Message & amp; "-" and formerly StackTrace) Lost Alst and Function< / Pre>My question is how can I customize this function in terms of the use of search indexes. I am running a program that calls this function several times on a large array and I was thinking that there is a better way to do this
This is C # - I have done it from memory, so there are probably some syntax errors in this
public class SearchLine {Private Hasheset < String & gt; word; Public zeros include words (hashsset> string> keywords) {if (word == empty) {words = new hashset & lt; String & gt; (); Foreign word (Line.plit ("") in the string S) {if (! String.IsNullOrEmpty (s)) word. Add (s.Treim ()); }} Change keywords. Overlaps (words); } Public string line {get; Private set; Public search line (string line) {line = line; }}
Comments
Post a Comment