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


C# IList.Last方法代码示例

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


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

示例1: GuerillaPreProcessMethod

 protected static void GuerillaPreProcessMethod(BinaryReader binaryReader, IList<tag_field> fields)
 {
     var field = fields.Last(x => x.type != field_type._field_terminator);
     fields.Remove(field);
     field = fields.Last(x => x.type != field_type._field_terminator);
     fields.Remove(field);
 }
开发者ID:jacksoncougar,项目名称:Moonfish-Editor,代码行数:7,代码来源:StructureBinarySeperationPlane.Code.cs

示例2: BuildLastSeason

        private IList<TripleExponentialEntry> BuildLastSeason(IList<TripleExponentialEntry> currSeason,
                                                              IEnumerable<DataEntry> dataEntries, int currPeriod)
        {
            //building the last season is similar to NextSeason, but uses the same Ft and Tt once calculated for the first entry.
            var currentFt = currSeason.Last().Ft;
            var currentTt = currSeason.Last().Tt;
            double currentSt = currSeason.Last().St, lastSt = currSeason.Last().St;
            var lastActual = dataEntries.Last().Value;
            IList<TripleExponentialEntry> newSeason = new List<TripleExponentialEntry>();

            currentFt = (_alpha*(lastActual/lastSt)) + ((1 - _alpha)*(currentTt + currentFt));
            currentTt = (_beta*(currentFt - currSeason.Last().Ft)) + ((1 - _beta)*currentTt);

            for (var currSeasonIndex = 1; currSeasonIndex <= _periodsPerSeason; currSeasonIndex++)
            {
                var lastPeriodActual =
                    dataEntries.ElementAt((currPeriod + currSeasonIndex) - _periodsPerSeason - 2).Value;
                var lastPeriodFt = currSeason.ElementAt(currSeasonIndex - 1).Ft;
                var lastPeriodSt = currSeason.ElementAt(currSeasonIndex - 1).St;

                currentSt = (_gamma*(lastPeriodActual/lastPeriodFt)) + ((1 - _gamma)*lastPeriodSt);

                newSeason.Add(new TripleExponentialEntry
                    {
                        Ft = currentFt,
                        Tt = currentTt,
                        St = currentSt,
                        Forecast = (currentFt + (currentTt*currSeasonIndex))*currentSt
                    });
            }

            return newSeason;
        }
开发者ID:klaforce,项目名称:Silas,代码行数:33,代码来源:TripleExponentialSmoothingStrategy.cs

示例3: Invoke

        public void Invoke(char[] code)
        {
            Tokens = new List<CToken>();
              var currentToken = new StringBuilder();
              // todo remove whitespace and comments

              foreach (char c in code)
              {
            if (char.IsWhiteSpace(c))
            {
              continue;
            }
            switch (c)
            {
              case Punctuations.OPEN_PARENS:
            Tokens.Add(new CToken(currentToken.ToString(), NodeType.Caller));
            Tokens.Add(new CToken(Punctuations.OPEN_PARENS.ToString(), NodeType.Punctuation));
            currentToken = new StringBuilder();
            break;
              case Punctuations.CLOSE_PARENS:
            Tokens.Add(new CToken(currentToken.ToString(), NodeType.Variable));
            Tokens.Add(new CToken(Punctuations.CLOSE_PARENS.ToString(), NodeType.Punctuation));
            currentToken = new StringBuilder();
            break;
              case Punctuations.COMMA:
            if (currentToken.Length != 0)
            {
              Tokens.Add(new CToken(currentToken.ToString(), NodeType.Variable));
            }
            Tokens.Add(new CToken(Punctuations.COMMA.ToString(), NodeType.Punctuation));
            currentToken = new StringBuilder();
            break;
              case Punctuations.DOUBLE_QUOTE:
            if (currentToken.Length == 0)
            {
              Tokens.Add(new CToken(Punctuations.DOUBLE_QUOTE.ToString(), NodeType.Punctuation));
            }
            else
            {
              Tokens.Add(new CToken(currentToken.ToString(), NodeType.String));
              Tokens.Add(new CToken(Punctuations.DOUBLE_QUOTE.ToString(), NodeType.Punctuation));
              currentToken = new StringBuilder();
            }
            break;
              case Punctuations.SEMI_COL:
            {
              Tokens.Add(new CToken(Punctuations.SEMI_COL.ToString(), NodeType.Punctuation));
              break;
            }
            }
            if (char.IsLetterOrDigit(c) || (Tokens.Last() != null && Tokens.Last().Value == "\"" && c != '"'))
            {
              currentToken.Append(c);
            }
              }
        }
开发者ID:GeertVL,项目名称:CBridge,代码行数:56,代码来源:Tokenizer.cs

示例4: PropertyAccessor

 public PropertyAccessor(IList<PropertyInfo> propertyChain, Type genericType, Type collectionType) : this(propertyChain)
 {
     if (genericType == null) throw new ArgumentNullException("genericType");
     GenericType = genericType;
     CollectionType = collectionType;
     AddMethod = CollectionType.GetMethod("Add");
     ItemPropertyInfo = propertyChain.Last().PropertyType.GetProperty("Item");
     RemoveAtMethod = propertyChain.Last().PropertyType.GetMethod("RemoveAt");
     IsCollection = true;
 }
开发者ID:npehrsson,项目名称:PatchingEventSourcing,代码行数:10,代码来源:PropertyAccessor.cs

示例5: AddWays

        public static void AddWays(this Polygon<OSMNode> polygon, IList<OSMWay> ways, OSMDB db)
        {
            if (ways.Count == 1) {
                // Check if the created polygon is closed
                if (ways[0].Nodes.Count > 0 && ways[0].Nodes.First() != ways[0].Nodes.Last()) {
                    throw new ArgumentException("Ways does not form a closed polygon");
                }

                for (int i = 0; i < ways[0].Nodes.Count - 1; i++) {
                    polygon.AddVertex(db.Nodes[ways[0].Nodes[i]]);
                }
            }
            else {
                int lastVertexID = 0;

                if (ways[0].Nodes.First() == ways.Last().Nodes.First() || ways[0].Nodes.Last() == ways.Last().Nodes.First()) {
                    lastVertexID = ways.Last().Nodes.First();
                }
                else {
                    lastVertexID = ways.Last().Nodes.Last();
                }
                //// Check orientation of the first way
                //if (ways[0].Nodes.First() == ways[1].Nodes.First() || ways[0].Nodes.First() == ways[1].Nodes.First()) {
                //  for (int ii = ways[0].; ii < verticesToAdd.Count - 1; ii++) {
                //    AddVertex(verticesToAdd[ii]);
                //  }
                //}

                for (int i = 0; i < ways.Count; i++) {
                    List<int> verticesToAdd = new List<int>();

                    // Checks the way orienatation and picks nodes in correct order
                    if (lastVertexID == ways[i].Nodes[0]) {
                        verticesToAdd.AddRange(ways[i].Nodes);
                    }
                    else if (lastVertexID == ways[i].Nodes.Last()) {
                        verticesToAdd.AddRange(ways[i].Nodes.Reverse());
                    }
                    else {
                        throw new ArgumentException("Can not create polygon, ways aren't connected");
                    }

                    for (int ii = 0; ii < verticesToAdd.Count - 1; ii++) {
                        polygon.AddVertex(db.Nodes[verticesToAdd[ii]]);
                    }

                    lastVertexID = verticesToAdd.Last();
                }

                // Check if the created polygon is closed
                if (polygon.VerticesCount > 0 && polygon.Vertices.First() != db.Nodes[lastVertexID]) {
                    throw new ArgumentException("Ways does not form a closed polygon");
                }
            }
        }
开发者ID:guifa,项目名称:traveltimeanalysis,代码行数:55,代码来源:GeoUtils.Extensions.cs

示例6: Filter

 static IEnumerable<BottomProfilePoint> Filter(IList<BottomProfilePoint> source)
 {
     var curProfilePoint = source[0];
     yield return curProfilePoint;
     foreach (var point in source.Where(point => curProfilePoint.Depth != point.Depth)) 
     {
         curProfilePoint = point;
         yield return point;
     }
     if (curProfilePoint.Range < source.Last().Range) yield return source.Last();
 }
开发者ID:AuditoryBiophysicsLab,项目名称:ESME-Workbench,代码行数:11,代码来源:BottomProfile.cs

示例7: AssignFragmentPeak

		public void AssignFragmentPeak(IList<IAtomContainer> fragments, IEnumerable<Peak> peakList, double mzabs, double mzppm)
		{
			hits = new List<PeakMolPair>();
			hitsAll = new List<PeakMolPair>();			

			foreach (var peak in peakList)
			{
				var haveFoundAMatch = false;
				foreach (var fragment in fragments)
				{
					//matched peak
					int hydrogensAdded;
					double matchedMass;
					double hydrogenPenalty;
					if (MatchByMass(fragment, peak.Mass, mzabs, mzppm, out matchedMass, out hydrogenPenalty, out hydrogensAdded))
					{
                        var match = new PeakMolPair(fragment, peak, matchedMass, GetMolecularFormulaAsString(fragment), hydrogenPenalty, double.Parse((string)fragment.getProperty("BondEnergy"), CultureInfo.InvariantCulture), GetNeutralChange(fragment, hydrogensAdded));
						hitsAll.Add(match);

						// If we don't yet have a match, add it
						if (!haveFoundAMatch)
						{
							hits.Add(match);
							haveFoundAMatch = true;
						}
						// If we do have a match, replace it if this new match has a lower hydrogen penalty
						else if (hydrogenPenalty < hits.Last().HydrogenPenalty)
						{
							hits.RemoveAt(hits.Count - 1);
							hits.Add(match);
						}						
					}
				}
			}
		}
开发者ID:NonlinearDynamics,项目名称:MetFrag.NET,代码行数:35,代码来源:FragmentPeakAssigner.cs

示例8: FromImportCompletionAnalysis

        public FromImportCompletionAnalysis(IList<ClassificationSpan> tokens, ITrackingSpan span, ITextBuffer textBuffer, CompletionOptions options)
            : base(span, textBuffer, options)
        {
            Debug.Assert(tokens[0].Span.GetText() == "from");

            int beforeImportToken = tokens
                .TakeWhile(tok => !(tok.ClassificationType.IsOfType(PredefinedClassificationTypeNames.Keyword) && tok.Span.GetText() == "import"))
                .Count();

            bool lastIsDot = tokens.Last().ClassificationType.IsOfType(JPredefinedClassificationTypeNames.Dot);
            _modulesOnly = beforeImportToken == tokens.Count;
            _noCompletions = !_modulesOnly && lastIsDot;
            _includeStar = beforeImportToken == tokens.Count - 1;

            if (beforeImportToken >= 2) {
                // If there are at least two tokens ('from' <name>) before the
                // 'import' token, use completions from that package.
                if (beforeImportToken < tokens.Count || lastIsDot) {
                    _namespace = tokens
                        .Take(beforeImportToken)
                        .Where(tok => tok.ClassificationType.IsOfType(PredefinedClassificationTypeNames.Identifier))
                        .Select(tok => tok.Span.GetText())
                        .ToArray();
                } else {
                    _importKeywordOnly = true;
                }
            }
        }
开发者ID:borota,项目名称:JTVS,代码行数:28,代码来源:FromImportCompletionAnalysis.cs

示例9: SortCollectedList

 void SortCollectedList()
 {
     var sorted = _collectedList.OrderByDescending(x => x.Value);
     _collectedList = null;
     _collectedList = sorted.Cast<MapData>().ToList();
     _lowest = _collectedList.Last().Value;
 }
开发者ID:bhabesh7,项目名称:bhabeshgitprojects,代码行数:7,代码来源:HuffAlgorithm.cs

示例10: PropertyExpression

        protected PropertyExpression(object obj, IEnumerable<PropertyExpressionPart> parts)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");
            if (parts == null)
                throw new ArgumentNullException("parts");
            /*foreach (object item in parts)
            {
                if (item == null)
                {
                    throw new ArgumentException("An item inside the enumeration was null.", "parts");
                }
            }*/
            if (parts.Cast<object>().Any(item => item == null))
            {
                throw new ArgumentException(Resources.AnItemWasNull, "parts");
            }

            _parts = new List<PropertyExpressionPart>(parts);

            if (_parts.Count == 0)
                throw new ArgumentException(Resources.OnePartRequired, "parts");

            _finalPart = _parts.Last();
            //whenever the final part's value changes, that means the value of the expression as a whole has changed
            _finalPart.ValueChanged += delegate
                {
                    OnValueChanged();
                };

            //assign the initial object in the potential chain of objects resolved by the expression parts
            _parts[0].Object = obj;
        }
开发者ID:tfreitasleal,项目名称:MvvmFx,代码行数:33,代码来源:PropertyExpression.cs

示例11: ParseRealization

 private void ParseRealization(IList<Double> realization)
 {
     Double repeatedValue = realization.Last(); // last value it's the same as cycle start value
     Int32 cycleStartIndex = realization.IndexOf(repeatedValue);
     Appendix = realization.Take(cycleStartIndex).ToList();
     Cycle = realization.Skip(cycleStartIndex).Take(realization.Count - cycleStartIndex - 1).ToList();
 }
开发者ID:romannort,项目名称:Modeling.LabOne,代码行数:7,代码来源:StatisticsResults.cs

示例12: CheckFirstAndLastPoint

 private void CheckFirstAndLastPoint(IList<Point> points)
 {
     if (this.DistanceIsTooSmall(points.Last(), points.First()))
     {
         points.RemoveAt(points.Count - 1);
     }
 }
开发者ID:an83,项目名称:KinectTouch2,代码行数:7,代码来源:LineThinner.cs

示例13: CheckFirstAndLastPoint

 private void CheckFirstAndLastPoint(IList<DepthPointEx> points)
 {
     if (PointsAreClose(points.Last(), points.First()))
     {
         points.RemoveAt(points.Count - 1);
     }
 }
开发者ID:guozanhua,项目名称:Kinect-Finger-Tracking,代码行数:7,代码来源:PointFilter.cs

示例14: MainWindow

        public MainWindow()
        {
            InitializeComponent();
            Loaded += (sender, e) => ClearValue(SizeToContentProperty);

            _allControllerViewModels =
                (from type in GetType().Assembly.GetTypes()
                 where !type.IsInterface && typeof(IController).IsAssignableFrom(type)
                 let viewModel = new ControllerViewModel((IController)Activator.CreateInstance(type))
                 orderby viewModel.SortIndex, viewModel.Library, viewModel.Description
                 select viewModel).ToList();
            _allControllerViewModels.First().IsChecked = true;
            ControllerGroups.ItemsSource = _allControllerViewModels.GroupBy(viewModel => viewModel.Library);

            _allResolutionViewModels = new[] {
                new ResolutionViewModel(800, 600, 50, 42),
                new ResolutionViewModel(1024, 768, 64, 54),
                new ResolutionViewModel(1280, 1024, 80, 73),
                new ResolutionViewModel(1440, 900, 90, 64),
            };
            _allResolutionViewModels.Last(
                res => res.Width <= SystemParameters.PrimaryScreenWidth &&
                res.Height <= SystemParameters.PrimaryScreenHeight).IsChecked = true;
            Resolutions.ItemsSource = _allResolutionViewModels;

            RunResults.ItemsSource = _runResults;
        }
开发者ID:joewhite,项目名称:Game-graphics,代码行数:27,代码来源:MainWindow.xaml.cs

示例15: SolveFive

 private int SolveFive(BombSettings settings, IList<Color> colors)
 {
     if (settings.SerialLastDigit == Parity.NotSet)
     {
         throw new NeedSerialLastDigitException();
     }
     // If the last wire is black and the last digit of the serial number is odd, cut the fourth wire.
     else if (colors.Last() == Color.Black && settings.SerialLastDigit == Parity.Odd)
     {
         return 4;
     }
     // Otherwise, if there is exactly one red wire and there is more than one yellow wire, cut the first wire.
     else if (colors.Count(c => c == Color.Red) == 1 && colors.Count(c => c == Color.Yellow) > 1)
     {
         return 1;
     }
     // Otherwise, if there are no black wires, cut the second wire.
     else if (colors.Count(c => c == Color.Black) == 0)
     {
         return 2;
     }
     // Otherwise, cut the first wire.
     else
     {
         return 1;
     }
 }
开发者ID:goosefraba19,项目名称:ktane-abe,代码行数:27,代码来源:WiresSolverTests.cs


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