public void LinearSearchTestDoesNotExist() { int[] arrayToSearch = { 1, 2, 3, 4, 5, 6 }; int queryItem = 9; Assert.False(MySearch.LinearSearchIntegers(arrayToSearch, queryItem)); }
public void BinarySearchDoesExist4() { int[] arrayToSearch = { 1, 2, 3, 4, 5, 6 }; int queryItem = 4; Assert.True(MySearch.BinarySearchIntegers(arrayToSearch, queryItem).Equals(3)); }
public void BinarySearchExistsKhan() { int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 }; var result = MySearch.BinarySearchIntegers(primes, 73); Assert.Equal(20, result); }
public void BinarySearchDoesNotExistOdd() { int[] arrayToSearch = { 1, 2, 3, 4, 5, 6, 7 }; int queryItem = 9; Assert.True(MySearch.BinarySearchIntegers(arrayToSearch, queryItem).Equals(-1)); }
protected void Page_Load(object sender, EventArgs e) { if (!Roles.IsUserInRole(ConfigurationManager.AppSettings["jobseekerrolename"])) { Response.Redirect("~/customerrorpages/NotAuthorized.aspx"); } if (!Page.IsPostBack) { FillCountries(); FillStates(); lblJobCount.Text = "(Currently we have " + JobPosting.GetJobPostingCount() + " jobs!!!)"; if (Request.QueryString["mysearchid"] != null) { MySearch s = MySearch.GetMySearch(int.Parse(Request.QueryString["mysearchid"])); txtSkills.Text = s.Criteria; txtCity.Text = s.City; ddlCountry.SelectedIndex = s.CountryID; FillStates(); ListItem li = ddlState.Items.FindByValue(s.StateID.ToString()); if (li != null) { ddlState.ClearSelection(); li.Selected = true; } } } }
/// <summary> /// Hàm xử lý khi được chọn Item tìm kiếm /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LvAutoComplete_ItemTapped(object sender, ItemTappedEventArgs e) { model.clubSearch.ListClub.Clear(); model.clubSearch.IsMore = false; var lv = sender as ListView; if (lv != null) { itemseleted = lv.SelectedItem as AutoComplete; lv.SelectedItem = null; } if (itemseleted != null) { model.clubSearch.isFreshing = true; MySearch.Text = itemseleted.TextShow; model.clubSearch.SearchAreaExe(itemseleted); Device.StartTimer(TimeSpan.FromMilliseconds(500), () => { model.clubSearch.isFreshing = false; return(false); }); lvAutoComplete.IsVisible = false; nearSearch.IsVisible = true; lvAutoComplete.BackgroundColor = Color.Transparent; // itemseleted = null; } MySearch.Unfocus(); }
public void BinarySearchDoesExistOdd3() { int[] arrayToSearch = { 1, 2, 3, 4, 5, 6, 7 }; int queryItem = 3; Assert.True(MySearch.ReverseBinarySearchIntegers(arrayToSearch, queryItem).Equals(2)); }
static void Main(string[] args) { CVehicle[] massTransport = new CVehicle[12]; massTransport[0] = new CCar("Car #1", 1000, 100, 2015, 0, 0, "Red"); massTransport[1] = new CPlane("Plane#1", 500000, 1000, 2010, 0, 0, 5000, 230); massTransport[2] = new CShip("Ship #1", 400000, 60, 2016, 0, 0, 500, "Kiyv"); massTransport[3] = new CCar("Car #2", 1200, 120, 2017, 0, 0, "Green"); massTransport[4] = new CPlane("Plane#2", 520000, 900, 2014, 0, 0, 7000, 120); massTransport[5] = new CShip("Ship #1", 420000, 40, 2018, 0, 0, 700, "Kiyv 1"); massTransport[6] = new CCar("Car #4", 1300, 120, 2016, 0, 0, "Yellow"); massTransport[7] = new CPlane("Plane#3", 530000, 1100, 2012, 0, 0, 8000, 280); massTransport[8] = new CShip("Ship #1", 430000, 30, 2014, 0, 0, 400, "Dnipro"); massTransport[9] = new CCar("Car #3", 1400, 130, 2015, 0, 0, "Blue"); massTransport[10] = new CPlane("Plane#4", 550000, 1200, 2011, 0, 0, 4000, 100); massTransport[11] = new CShip("Ship #1", 460000, 70, 2017, 0, 0, 520, "Chernigov"); Console.WriteLine("1. Найти транспортное стредство от 2011 до 2015 года выпуска"); Console.WriteLine("2. Найти транспортное стредство со скоростью от 70 до 900 км/час "); Console.WriteLine("3. Найти транспортное стредство с посадочными местами от 150 до 500"); Console.WriteLine("4. Найти транспортное стредство красного цвета"); Console.WriteLine("Введите пункт меню"); int MenuItem; int.TryParse(Console.ReadLine(), out MenuItem); Console.WriteLine("Результат поиска"); switch (MenuItem) { case 1: MySearch.VehicleYear(massTransport, 2015, 2011); break; case 2: MySearch.VehicleSpeed(massTransport, 900, 70); break; case 3: MySearch.VehiclePassengerCapacity(massTransport, 500, 150); break; case 4: MySearch.VehicleColor(massTransport, "Red"); break; default: break; } Console.WriteLine("Полный список"); foreach (var item in massTransport) { Console.WriteLine(item.ToString()); } Console.ReadLine(); }
protected void ImageButton3_Click(object sender, ImageClickEventArgs e) { MySearch s = new MySearch(); s.Criteria = txtSkills.Text; s.CountryID = int.Parse(ddlCountry.SelectedValue); s.StateID = int.Parse(ddlState.SelectedValue); s.City = txtCity.Text; s.UserName = Profile.UserName; MySearch.Insert(s); }
private void MsgBox_Load(object sender, EventArgs e) { MySearch mys = new MySearch(search_date, AVI); mys.SearchStrUseTh(); while (true) { if (mys.complete) { this.BeginInvoke(new Action(() => { this.Close(); })); break; } Thread.Sleep(10); } }
static void Main(string[] args) { var csvReader = new CSVreader(); var mySearch = new MySearch(); //Linear and Binary, Binary should only sort sorted data var mySort = new MySort(); //Insert and Shell string path = "C:/Users/New/Documents/visual studio 2017/Projects/Algorithms1Console/unsorted_numbers.csv"; int[] data = csvReader.ReadFile(path); // comment out unnecessary stuff int[] sorted = mySort.InsertionSort(data); Console.WriteLine("Linear Search"); var linearstopwatch = Stopwatch.StartNew(); mySearch.LinearSearchHighest(data); linearstopwatch.Stop(); Console.WriteLine("Linear Search: " + ((linearstopwatch.Elapsed.TotalMilliseconds).ToString())); Console.WriteLine(); //Console.WriteLine("Binary Search"); //var binarystopwatch = Stopwatch.StartNew(); //mySearch.LinearSearchHighest(data); //binarystopwatch.Stop(); //Console.WriteLine("Binary Search: " + ((binarystopwatch.Elapsed.TotalMilliseconds).ToString())); //Console.WriteLine(); Console.WriteLine("Linear 1500th Search"); var linear1500thstopwatch = Stopwatch.StartNew(); mySearch.LinearSearchEvery1500th(sorted); linear1500thstopwatch.Stop(); Console.WriteLine("Linear 1500th Search: " + ((linear1500thstopwatch.Elapsed.TotalMilliseconds).ToString())); Console.WriteLine(); //Console.WriteLine("Binary 1500th Search"); //var binary1500thstopwatch = Stopwatch.StartNew(); //mySearch.BinarySearchEvery1500th(sorted); //binary1500thstopwatch.Stop(); //Console.WriteLine("Binary 1500th Search: " + ((binary1500thstopwatch.Elapsed.TotalMilliseconds).ToString())); Console.ReadKey(); }
/// <summary> /// Chọn item trong danh sách autoComplete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LvAutoComplete_ItemTapped(object sender, ItemTappedEventArgs e) { var lv = sender as ListView; if (lv != null) { itemseleted = lv.SelectedItem as AutoComplete; lv.SelectedItem = null; } if (itemseleted != null) { MySearch.Text = itemseleted.TextShow; model.SearchLocation.SearchAreaExe(itemseleted); lvAutoComplete.IsVisible = false; lvAutoComplete.BackgroundColor = Color.Transparent; itemseleted = null; } MySearch.Unfocus(); }
public static IEnumerable<inTheater> apiSearch() { HttpClient myClient = new HttpClient(); myClient.BaseAddress = new Uri("http://api.myapifilms.com/imdb/comingSoon/"); myClient.DefaultRequestHeaders.Accept.Clear(); myClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); string token = "a3a9d437-81bc-425f-a1ca-3583f0dbe27f"; List<inTheater> result = new List<inTheater>(); HttpResponseMessage response = myClient.GetAsync("?token=" + token + "&format=json&language=en-us&date="+DateTime.Now.Year).Result; if (response.IsSuccessStatusCode) { MySearch comingSoon = new MySearch(); comingSoon = response.Content.ReadAsAsync<MySearch>().Result; result = comingSoon.data.inTheaters; } return result; }
public DataTable GetDataTable(DO_SaveMySearch objSave, MySearch flag) { DataTable dt = new DataTable(); SqlConnection conn = new SqlConnection(); SQLManager co = new SQLManager(); conn = co.GetConnection(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand("Scrl_AddEditDelSavedMySearch", conn); da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.Parameters.Add("@FlagNo", SqlDbType.Int).Value = flag; da.SelectCommand.Parameters.Add("@intMySearchId", SqlDbType.Int).Value = objSave.intMySaveSearchId; da.SelectCommand.Parameters.Add("@intAddedBy", SqlDbType.Int).Value = objSave.intAddedBy; da.SelectCommand.Parameters.Add("@intSubjectCategoryId", SqlDbType.Int).Value = objSave.intSubjectCategoryId; da.SelectCommand.Parameters.Add("@Ids", SqlDbType.VarChar, 150).Value = objSave.Ids; da.SelectCommand.Parameters.Add("@PageSize", SqlDbType.Int).Value = objSave.PageSize; da.SelectCommand.Parameters.Add("@Currentpage", SqlDbType.Int).Value = objSave.Currentpage; da.Fill(dt); co.CloseConnection(conn); return(dt); }
public void AddEditDel_Searchs(DO_SaveMySearch objSave, MySearch flag) { SqlConnection conn = new SqlConnection(); SQLManager co = new SQLManager(); conn = co.GetConnection(); cmd = new SqlCommand("Scrl_AddEditDelSavedMySearch", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@FlagNo", SqlDbType.Int).Value = flag; cmd.Parameters.Add("@intMySearchId", SqlDbType.Int).Value = objSave.intMySaveSearchId; cmd.Parameters.Add("@intDocId", SqlDbType.Int).Value = objSave.intDocId; cmd.Parameters.Add("@intDocTypeId", SqlDbType.Int).Value = objSave.intDocTypeId; cmd.Parameters.Add("@strSavedMyTitle", SqlDbType.VarChar, 100).Value = objSave.strSavedMyTitle; cmd.Parameters.Add("@strSearchQuery", SqlDbType.VarChar, 1000).Value = objSave.strSearchQuery; cmd.Parameters.Add("@strSearchFor", SqlDbType.VarChar, 500).Value = objSave.strSearchFor; cmd.Parameters.Add("@strPreSearchedIn", SqlDbType.VarChar, 200).Value = objSave.strPreSearchedIn; cmd.Parameters.Add("@strDocumentType", SqlDbType.VarChar, 150).Value = objSave.strDocumentType; cmd.Parameters.Add("@strLookInto", SqlDbType.VarChar, 50).Value = objSave.strLookInto; cmd.Parameters.Add("@strAdvSearchTitle", SqlDbType.VarChar, 500).Value = objSave.strAdvSearchTitle; cmd.Parameters.Add("@strAdvJuridiction", SqlDbType.VarChar, 100).Value = objSave.strAdvJuridiction; cmd.Parameters.Add("@strAdvCitation", SqlDbType.VarChar, 100).Value = objSave.strAdvCitation; cmd.Parameters.Add("@strAdvDateFrom", SqlDbType.VarChar, 10).Value = objSave.strAdvDateFrom; cmd.Parameters.Add("@strAdvDateTo", SqlDbType.VarChar, 10).Value = objSave.strAdvDateTo; cmd.Parameters.Add("@strAdvProvision", SqlDbType.VarChar, 100).Value = objSave.strAdvProvision; cmd.Parameters.Add("@strAdvPartyName", SqlDbType.VarChar, 100).Value = objSave.strAdvPartyName; cmd.Parameters.Add("@strAdvBench", SqlDbType.VarChar, 100).Value = objSave.strAdvBench; cmd.Parameters.Add("@strAdvJudgeName", SqlDbType.VarChar, 150).Value = objSave.strAdvJudgeName; cmd.Parameters.Add("@strContextId", SqlDbType.VarChar, 150).Value = objSave.strContextId; cmd.Parameters.Add("@strIpAddress", SqlDbType.VarChar, 20).Value = objSave.strIpAddress; cmd.Parameters.Add("@intSubjectCategoryId", SqlDbType.Int).Value = objSave.intSubjectCategoryId; cmd.Parameters.Add("@intAddedBy", SqlDbType.Int).Value = objSave.intAddedBy; cmd.Parameters.Add("@intSearchResultCount", SqlDbType.Int).Value = objSave.intSearchResultCount; cmd.ExecuteNonQuery(); co.CloseConnection(conn); }
/* [System.Web.Mvc.HttpPost] public ActionResult Search() { return View(); }*/ public static IEnumerable<Movie> apiSearch(string searchString) { HttpClient myClient = new HttpClient(); // New code: myClient.BaseAddress = new Uri("http://api.myapifilms.com/imdb/idIMDB/"); myClient.DefaultRequestHeaders.Accept.Clear(); myClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); string token = "a3a9d437-81bc-425f-a1ca-3583f0dbe27f"; List<Movie> result = new List<Movie>(); //alterei o codigo de maneira a responder da mesma maneira como se estivesse a trabalhar como async HttpResponseMessage response = myClient.GetAsync("?title=" + searchString + "&token=" + token + "&format=json&language=en-us&aka=0&business=0&seasons=0&seasonYear=0&technical=0&filter=3&exactFilter=0&limit=10&forceYear=0&trailers=0&movieTrivia=0&awards=0&moviePhotos=0&movieVideos=0&actors=0&biography=0&uniqueName=0&filmography=0&bornAndDead=0&starSign=0&actorActress=0&actorTrivia=0&similarMovies=0&adultSearch=0").Result; //HttpResponseMessage response = myClient.GetAsync("?s=" + searchString + "&y=&plot=short&r=json&type=movie").Result; if (response.IsSuccessStatusCode) { MySearch moviedata = new MySearch(); moviedata = response.Content.ReadAsAsync<MySearch>().Result; result = moviedata.data.movies; } return result; }