当前位置: 首页>>代码示例>>C#>>正文


C# List.Remove方法代码示例

本文整理汇总了C#中Model.List.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# List.Remove方法的具体用法?C# List.Remove怎么用?C# List.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model.List的用法示例。


在下文中一共展示了List.Remove方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetExchangePeriodsMergedByMovementDirectoryFromStartDate

        /// <summary>
        /// Metoda zwracająca listę okresów notowań połączonych, jeżeli mają ten sam kierunek trendu. Metoda ta rozpoczyna wyznaczanie od parametru periodsStartDate i zmierza ku teraźniejszości.
        /// </summary>
        /// <param name="DesiredNumberOfPeriods">Oczekiwana liczba okresów.</param>
        /// <param name="periodsEndDate">Data będąda granicą wyznaczania kolejnych okresów.</param>
        /// <param name="periodsStartDate">Data początku okresów.</param>
        /// <param name="daysInterval">Liczba określająca długość okresu w dniach.</param>
        /// <returns>Lista okresów notowań połaczonych, jeżeli mają ten sam kierunek trendu.</returns>
        public List<ExchangePeriod> GetExchangePeriodsMergedByMovementDirectoryFromStartDate(int DesiredNumberOfPeriods, DateTime periodsEndDate, DateTime periodsStartDate, int daysInterval)
        {
            DateTime iterationDate = periodsStartDate.Date;
            string dataPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\data\\";
            List<ExchangePeriod> periodList = new List<ExchangePeriod>();
            while (periodList.Count <= DesiredNumberOfPeriods && iterationDate <= periodsEndDate)
            {
                DateTime periodEnd;
                if (iterationDate.AddDays(daysInterval) < periodsEndDate)
                {
                    periodEnd = iterationDate.AddDays(daysInterval);
                }
                else
                {
                    periodEnd = periodsEndDate.Date;
                }

                ExchangePeriod period = GetExchangePeriod(iterationDate, periodEnd);
                if (period != null)
                {
                    if (periodList.Count != 0)
                    {
                        if (period.PeriodStart == periodList.Last().PeriodEnd)
                        {
                            period.PublicTrading -= GetExchangeDay(periodList.Last().PeriodEnd).PublicTrading;
                        }

                        //If percentage changes have the same sign.
                        if ((periodList.Last().PercentageChange * period.PercentageChange) >= 0)
                        {
                            periodList.Last().PeriodEnd = period.PeriodEnd;
                            periodList.Last().PublicTrading += period.PublicTrading;
                            periodList.Last().CloseRate = period.CloseRate;
                        }
                        else
                        {
                            period.OpenRate = periodList.Last().CloseRate;
                            periodList.Add(period);
                        }
                    }
                    else
                    {

                        period.PublicTrading -= GetExchangeDay(period.PeriodStart).PublicTrading;
                        periodList.Add(period);
                    }
                }

                iterationDate = iterationDate.AddDays(daysInterval);
            }

            while (periodList.Count > DesiredNumberOfPeriods)
            {
                periodList.Remove(periodList.Last());
            }

            return periodList;
        }
开发者ID:sharpgienek,项目名称:Polsl-BMMSI-Predict-WIG20-longterm-trend,代码行数:66,代码来源:DataProvider.cs

示例2: GetResumeField

        /// <summary>
        /// Gets the resume field.
        /// </summary>
        protected List<ResumeField> GetResumeField()
        {
            var result = new List<ResumeField>();
            foreach (RepeaterItem filed in fieldRepeater.Items)
            {
                var lbl = (Label)filed.FindControl("field");
                var listView = (ListView)filed.FindControl("themeListView");
                var item = new ResumeField
                {
                    FieldName = lbl.Text,
                    Theme = new List<ResumeTheme>()
                };

                foreach (var theme in listView.Items)
                {
                    var skill = (DropDownList)theme.FindControl("themeSkils");
                    if (skill.SelectedIndex == 0) continue;

                    var themeId = (Label)theme.FindControl("themeId");
                    var themeName = (Label)theme.FindControl("theme");

                    item.Theme.Add(new ResumeTheme
                                       {
                                           SkillId = Convert.ToInt32(skill.SelectedValue),
                                           SkillName = skill.SelectedItem.Text,
                                           ThemeId = Convert.ToInt32(themeId.Text),
                                           ThemeName = themeName.Text
                                       });
                }
                result.Add(item);
            }
            foreach (var item in result.Where(item => item.Theme.Count == 0))
            {
                result.Remove(item);
            }
            return result;
        }
开发者ID:wegorich,项目名称:AccountingKnowledge-ASP-WebForms,代码行数:40,代码来源:ResumeConstructor.aspx.cs

示例3: Generate

 public void Generate() {
   List<GetReservation_Result> ClientsToSeat = new List<GetReservation_Result>();
   Table CurrentTable = new Table(_nbSeats);
   bool goodFeeling;
   bool found;
   _tablesMaps = null;
   _disliked = new List<Disliked>();
   foreach(GetReservation_Result client in _clients.Where(client => client.IsValid == true)) {
     ClientsToSeat.Add(client);
     _disliked.Add(new Disliked(client.ClientId));
   }
   while(ClientsToSeat.Count > 0) {
     foreach(GetReservation_Result CurrentClient in ClientsToSeat.ToList()) {
       if(CurrentTable.HasRemainingSeats) {
         goodFeeling = true;
         foreach(GetReservation_Result seated in CurrentTable.Seateds) {
           if(HasBadFeeling(CurrentClient.ClientId, seated.ClientId)) { // BR024
             goodFeeling = false;
             break;
           }
         }
         if(goodFeeling) {
           CurrentTable.Add(CurrentClient);
           ClientsToSeat.Remove(CurrentClient);
         }
       } else {
         break;
       }
     }
     Tables.Add(CurrentTable);
     CurrentTable = new Table(_nbSeats);
   }
   foreach(Table table in Tables.Where(table => !table.isValid).ToList()) {
     if(table.Seateds.Count > 0) {
       GetReservation_Result seated = table.Seateds[0];
       foreach(Table otherTable in Tables.Where(tbl => tbl.isValid && tbl.HasRemainingSeats)) {
         goodFeeling = true;
         foreach(GetReservation_Result otherSeated in otherTable.Seateds) {
           if(HasBadFeeling(seated.ClientId, otherSeated.ClientId)) { // BR024
             goodFeeling = false;
             break;
           }
         }
         if(goodFeeling) {
           otherTable.Add(seated);
           Tables.Remove(table);
           break;
         }
       }
     } else {
       Tables.Remove(table);
     }
   }
   foreach(Table table in Tables.Where(table => !table.isValid).ToList()) {
     GetReservation_Result seated = table.Seateds[0];
     foreach(Table otherTable in Tables.Where(tbl => tbl.isValid && tbl.Seateds.Count > 2)) {
       found = false;
       foreach(GetReservation_Result otherSeated in otherTable.Seateds) {
         if(!HasBadFeeling(seated.ClientId, otherSeated.ClientId)) { // BR024
           otherTable.Seateds.Remove(otherSeated);
           table.Add(seated);
           found = true;
           break;
         }
       }
       if(found) {
         break;
       }
     }
   }
 }
开发者ID:tykamara,项目名称:ephec_projet_sgbd,代码行数:71,代码来源:TablesMapGenerator.cs

示例4: AddTalks

 /// <summary>
 /// Adds the talks to this session.
 /// </summary>
 /// <param name="scheduledTalks">The scheduled talks.</param>
 /// <param name="unscheduledTalks">The unscheduled talks.</param>
 public void AddTalks(List<ITalk> scheduledTalks, List<ITalk> unscheduledTalks)
 {
     if (null != scheduledTalks && scheduledTalks.Count != 0)
     {
         foreach (ITalk scheduledTalk in scheduledTalks)
         {
             /* This method has more than one responsibility on purpose.
              * Just remove the talk from unscheduled talks once it is scheduled.*/
             AddTalk(scheduledTalk);
             if (unscheduledTalks.Contains(scheduledTalk))
                 unscheduledTalks.Remove(scheduledTalk);
         }
     }
 }
开发者ID:srihari-sridharan,项目名称:Programming-Playground,代码行数:19,代码来源:Session.cs

示例5: Approach

        private int[] Approach(double beta, int[] xi, int[] xj)
        {
            //var rand = new Random();
            //var n = xi.Length;
            var result = new int[n]; //result
            HashSet<int> valuesLeft = new HashSet<int>(Enumerable.Range(0, n)); // {0, 1, ..., n-1} possible values
            var gaps = new List<int>(); //indFree  //indexes of gaps which still need to be filled
            var gapsToRandomize = new List<int>(); //gaps for which there is no rescue

            // najpierw przepisujemy te miejsca ktore sie zgadzaja
            // tworzymy zbior wartosci do obsadzenia i miejsc w ktorych mozna obsadzic wartosci
            for (int i = 0; i < n; i++)
            {
                if (xi[i] == xj[i])
                {
                    result[i] = xi[i];
            //                    valuesLeft.Remove(result[i]);
                    if (!valuesLeft.Remove(result[i]))
                        throw new Exception("Blad - wartosci mialy sie nie powtarzac!");
                }
                else
                {
                    result[i] = -1;
                    gaps.Add(i);
                }
            }
            while (gaps.Count > 0)
            {
                int tmp = gaps[rand.Next(gaps.Count)];
                int pickedValue = rand.NextDouble() < beta ? xj[tmp] : xi[tmp];
                if(valuesLeft.Contains(pickedValue))
                {
                    result[tmp] = pickedValue;
                    if(!valuesLeft.Remove(result[tmp]) )
                        throw new Exception("Blad - wartosci mialy sie nie powtarzac!");
                }
                else
                {
                    gapsToRandomize.Add(tmp);
                }
                gaps.Remove(tmp);
            }

            if (gapsToRandomize.Count + 1 == valuesLeft.Count()) throw new Exception("Dokladnie o 1 wiecej wartosci!");
            if(gapsToRandomize.Count != valuesLeft.Count()) throw new Exception("Liczba pozostalych luk jest inna niz liczba pozostalych wartosci!");
            var valuesLeftAsList = valuesLeft.ToList();
            foreach (var gap in gapsToRandomize)
            {
                result[gap] = valuesLeftAsList.ElementAt(rand.Next(valuesLeftAsList.Count));
                valuesLeftAsList.Remove(result[gap]);
            }
            if(valuesLeftAsList.Any()) throw new Exception("blad : zostaly jakies wartosci");

            return result;
        }
开发者ID:Kristofers93,项目名称:qap-project,代码行数:55,代码来源:FireflyAlgorithm.cs

示例6: createIteration1PatientsAndVisits

        //generate data for iteration 1
        public void createIteration1PatientsAndVisits(int numberOfPatients)
        {
            Random random = new Random();
            List<Patient> patients = new List<Patient>();
            List<Patient> globallySimilarPatients = new List<Patient>();
            List<Patient> globallyNonSimilarPatients = new List<Patient>();
            List<PatientMatchNode> patientMatchNodes = new List<PatientMatchNode>();
            float globallySimilarPatientsThreshold = 0.1f;
            float globallyNonSimilarPatientsThreshold = 0.1f;
            int requiredNumberOfGloballySimilarPatients = (int)((globallySimilarPatientsThreshold * numberOfPatients) + 0.5f);
            int requiredNumberOfGloballyNonSimilarPatients = (int)((globallyNonSimilarPatientsThreshold * numberOfPatients) + 0.5f);
            int currentNumberOfGloballySimilarPatients = 0;
            int currentNumberOfGloballyNonSimilarPatients = 0;
            DateTime maxRangeStart = new DateTime(2011, 01, 01);
            DateTime maxRangeEnd = new DateTime(2011, 12, 31);
            DateTime rangeStart = Util.getRandomDate(maxRangeStart, maxRangeEnd.AddMonths(-1));
            DateTime rangeEnd = rangeStart.AddDays(15);

            int randRationalMin = 1;
            int randRationalMax = 5;

            DbMethods.getInstance().clearTables();

            for (int i = 0; i < numberOfPatients; i++)
            {
                int patientID = i;
                DbMethods.getInstance().InsertPatient();
                Patient patient = new Patient(patientID);
                PatientMatchNode patientNode = new PatientMatchNode(patient);

                int numberOfVisits = random.Next(10, 20);
                bool restart = true;

                do
                {
                    patient.ClearVisits();

                    //generate directed visits
                    for (int j = 0; j < numberOfVisits; j++)
                    {
                        Visit v = new Visit(-1, random.Next(1, 100), random.Next(randRationalMin, randRationalMax), Util.getRandomDate(rangeStart, rangeEnd));
                        if (!patient.HasVisit(v))
                        {
                            patient.AddVisit(v);
                        }
                        else
                        {
                            j--;
                        }
                    }

                    if (requiredNumberOfGloballySimilarPatients > 0)
                    {
                        //SIMILAR PATIENTS

                        foreach (PatientMatchNode n in patientMatchNodes)
                        {
                            if (n.Patient.HasSimilarVisits(patient, 0.5f))
                            {
                                n.addMatch(patient);
                                restart = false;
                            }
                        }

                        List<PatientMatchNode> nodesToRemove = new List<PatientMatchNode>();
                        foreach (PatientMatchNode n in patientMatchNodes)
                        {
                            if (n.getMatchesNumber() >= 4)
                            {
                                requiredNumberOfGloballySimilarPatients--;
                                globallySimilarPatients.Add(n.Patient);
                                nodesToRemove.Add(n);
                            }
                        }

                        foreach (PatientMatchNode n in nodesToRemove)
                        {
                            patientMatchNodes.Remove(n);
                        }

                        nodesToRemove.Clear();

                        if(patientMatchNodes.Count < requiredNumberOfGloballySimilarPatients)
                        {
                            patientMatchNodes.Add(patientNode);
                            restart = false;
                        }

                    }
                    else if (requiredNumberOfGloballyNonSimilarPatients > 0)
                    {
                        //NON-SIMILAR PATIENTS
                        rangeStart = maxRangeStart;
                        rangeEnd = maxRangeEnd;

                        bool hasSimilar = false;
                        foreach (Patient p in patients)
                        {
                            if (!patient.HasNoSimilarVisits(p))
//.........这里部分代码省略.........
开发者ID:patpaquette,项目名称:Cheo-visits,代码行数:101,代码来源:Controller.cs


注:本文中的Model.List.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。