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


C# List.Last方法代码示例

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


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

示例1: EliminateRootNoRemainder

 /// <summary>Uses Ruffini's rule</summary>
 public PolynomialEq EliminateRootNoRemainder(double root)
 {
     List<double> tempList = new List<double>(coefficients.Count);
     List<double> newCoef = new List<double>(coefficients.Count); //last guy is the remainder
     newCoef.Add(coefficients[0]);
     for (int i = 1; i < coefficients.Count - 1; i++) {
         tempList.Add( newCoef.Last()* root);
         newCoef.Add(coefficients[i] + tempList.Last());
     }
     return new PolynomialEq(newCoef.ToArray());
 }
开发者ID:Amichai,项目名称:OpenPadProject,代码行数:12,代码来源:PolynomialEquation.cs

示例2: TestForTokenInference

 public static Token TestForTokenInference(List<Token> tokens, Token tokenToAdd)
 {
     if (tokens.Count() > 0) {
         //When a minus or plus sign is read as a negative number, add a plus sign before the number
         //IE: 4 -5 becomes 4 + -5
         TokenizerRules.CharInfo lastTknInfo = TokenizerRules.CharacterInfo.GetCharInfo(tokens.Last().TokenString);
         TokenizerRules.CharInfo currentTknInfo = TokenizerRules.CharacterInfo.GetCharInfo(tokenToAdd.TokenString);
         TokenizerRules.CharInfo lastCharInfo = TokenizerRules.CharacterInfo.GetCharInfo(tokenToAdd.TokenString[0].ToString());
         if ((tokenToAdd.TokenType == TokenType.numberLiteral)
             && (tokens.Last().TokenType == TokenType.numberLiteral
                     || (lastTknInfo != null && lastTknInfo.Type == TokenizerRules.CharType.closedBrace))
                     || ((Keywords.KeywordLookup.ContainsKey(tokens.Last().TokenString.ToLower()) && Keywords.KeywordLookup[tokens.Last().TokenString.ToLower()].TokenType == TokenType.numberLiteral)
             && (lastCharInfo != null && lastCharInfo.Type == TokenizerRules.CharType.plusMinus))) {
             return new Token("+", TokenType.operatorOrPunctuation);
         }
         //Infer a multiplication sign between two sets of parenthesis
         //IE: (3)(5) becomes (3)*(5)
         if ((TokenizerRules.CharacterInfo.ContainsKey(tokenToAdd.TokenString) && TokenizerRules.CharacterInfo.ContainsKey(tokens.Last().TokenString))
             && TokenizerRules.CharacterInfo[tokenToAdd.TokenString].Type == TokenizerRules.CharType.openBrace
             && TokenizerRules.CharacterInfo[tokens.Last().TokenString].Type == TokenizerRules.CharType.closedBrace) {
                 return new Token("*", TokenType.operatorOrPunctuation);
         }
         //Infer a multiplication sign between parenthesis and a number (that doesn't start with a minus sign)
         //IE: 3(4) becomes 3*(4)
         if (TokenizerRules.CharacterInfo.ContainsKey(tokenToAdd.TokenString)
             && TokenizerRules.CharacterInfo[tokenToAdd.TokenString].Type == TokenizerRules.CharType.openBrace
             && tokens.Last().TokenType == TokenType.numberLiteral) {
             return new Token("*", TokenType.operatorOrPunctuation);
         }
         //IE: (4)3 becomes (4)*3
         if (TokenizerRules.CharacterInfo.ContainsKey(tokens.Last().TokenString)
             && tokenToAdd.TokenType == TokenType.numberLiteral
             && TokenizerRules.CharacterInfo[tokens.Last().TokenString].Type == TokenizerRules.CharType.closedBrace
             && tokenToAdd.TokenString[0] != '-') {
             return new Token("*", TokenType.operatorOrPunctuation);
         }
     }
     return null;
 }
开发者ID:Amichai,项目名称:OpenPadProject,代码行数:39,代码来源:OperatorInferenceRules.cs

示例3: GetRandomRoute

        private IEnumerable<RouteElement> GetRandomRoute( IRoadElement startElement )
        {
            var result = new List<RouteElement>
                             {
                                 new RouteElement
                                     {
                                         CanStopOnIt = true,
                                         PriorityType = PriorityType.None,
                                         RoadElement = startElement
                                     }
                             };

            result.AddRange( startElement.Routes.GetRandomRoute( this._rng ) );

            while ( true )
            {
                var nextRoute = result.Last().RoadElement.Routes.GetRandomRoute( this._rng ).ToArray();
                if ( nextRoute.Length == 0 ) { break; }

                result.AddRange( nextRoute );
            }
            return result;
        }
开发者ID:Klakier,项目名称:Road-Traffic-Simualator,代码行数:23,代码来源:PassengerCarFactory.cs

示例4: LoadPostPictures

        public FilesUploadResult LoadPostPictures(int id)
        {
            List<string> result = new List<string>();
            UserDTO user = _userSvc.Get(id);
            string rootPath = HttpContext.Current.Request.MapPath("~/Temp/");
            string userDirectoryPath = Path.Combine(rootPath, user.email);
            if (!Directory.Exists(userDirectoryPath))
            {
                string standartImageDirectoryPath = Path.Combine(userDirectoryPath, "Standart");
                string mediumImageDirectoryPath = Path.Combine(userDirectoryPath, "Medium");
                string smallImageDirectoryPath = Path.Combine(userDirectoryPath, "Small");
                Directory.CreateDirectory(userDirectoryPath);
                Directory.CreateDirectory(standartImageDirectoryPath);
                Directory.CreateDirectory(mediumImageDirectoryPath);
                Directory.CreateDirectory(smallImageDirectoryPath);
            }

            var httpRequest = HttpContext.Current.Request;

            if (httpRequest.Files.Count > 0)
            {
                FilesUploadResult res = new FilesUploadResult { };
                foreach (string file in httpRequest.Files)
                {

                    var postedFile = httpRequest.Files[file];
                    result.Add(Convert.ToString(Guid.NewGuid() + Path.GetExtension(postedFile.FileName)));
                    var standartImagePath = HttpContext.Current.Server.MapPath("~/temp/" + user.email + "/Standart/" + result.Last());
                    var mediumImagePath = HttpContext.Current.Server.MapPath("~/temp/" + user.email + "/Medium/" + result.Last());
                    var smallImagePath = HttpContext.Current.Server.MapPath("~/temp/" + user.email + "/Small/" + result.Last());
                    postedFile.SaveAs(standartImagePath);
                    PictureProvider.SaveMiniatureImage(standartImagePath, mediumImagePath, 200);
                    PictureProvider.SaveMiniatureImage(standartImagePath, smallImagePath, 100);
                    res.Files = new List<FileUploadResult>
                        {
                            new FileUploadResult {
                                Name = postedFile.FileName,
                                Size = postedFile.ContentLength,
                                Url = "/temp/" + user.email + "/Standart/" + result.Last(),
                                DeleteUrl = "http://test",
                                DeleteType = "DELETE",
                                ThumbnailUrl = "/temp/" + user.email + "/Medium/" + result.Last(),
                                NewName = result.Last()
                            }
                        };
                }
                return res;
            }
            else
            {
                throw new Exception();
            }
        }
开发者ID:Nalivaich,项目名称:socNetwork,代码行数:53,代码来源:UserController.cs

示例5: suggestSellPrice

        private double suggestSellPrice(List<Order> asks)
        {
            if (null == asks || !asks.Any())
            {
                return _sellOrderPrice > 0.0 ? _sellOrderPrice : _minSellPrice;
            }

            const int DEC_PLACES = 14;
            double increment = 2.0 * _minPriceUpdate;

            //Find first ASK price higher than minPrice
            foreach (Order ask in asks)
            {
                //Don't consider own order
                if (ask.SequenceNumber == _sellOrderId)   //TODO: this is a pure guess. In case orderbook bid/ask cannot be matched with my order, use old method (price and amount equality)
                {
                    continue;
                }

                if (ask.Price >= _minSellPrice)
                {
                    double sellPrice = Math.Round(ask.Price - increment, DEC_PLACES);

                    //The difference is too small. Leave previous price to avoid server call
                    if (-1 != _sellOrderId && Math.Abs(sellPrice - _sellOrderPrice) < _minPriceUpdate)
                    {
                        log(String.Format("DEBUG: SELL price {0:0.00000} too similar, using previous", sellPrice));
                        return _sellOrderPrice;
                    }

                    if (sellPrice > _maxSellPrice)
                    {
                        return _maxSellPrice;
                    }
                    return sellPrice;
                }
            }

            //Order book filled with junk. Use order before last, so we see it in chart
            double price = asks.Last().Price - increment;
            if (-1 != _sellOrderId && Math.Abs(price - _sellOrderPrice) < _minPriceUpdate)
            {
                return _sellOrderPrice;
            }
            return Math.Round(price, DEC_PLACES);
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:46,代码来源:DirectArbitrage.cs

示例6: suggestBuyPrice

        private double suggestBuyPrice(List<Order> bids)
        {
            if (null == bids || !bids.Any())
            {
                return _buyOrderPrice > 0.0 ? _buyOrderPrice : _maxBuyPrice;
            }

            const int DEC_PLACES = 14;
            double increment = 2.0 * _minPriceUpdate;

            //Find first BID price lower than max. price
            foreach (Order bid in bids)
            {
                //Don't consider own order
                if (bid.SequenceNumber == _sellOrderId)   //TODO: this is a pure guess. In case orderbook bid/ask cannot be matched with my order, use old method (price and amount equality)
                {
                    continue;
                }

                if (bid.Price <= _maxBuyPrice)
                {
                    double buyPrice = Math.Round(bid.Price + increment, DEC_PLACES);

                    //The difference is too small. Leave previous price to avoid server call
                    if (-1 != _buyOrderId && Math.Abs(buyPrice - _buyOrderPrice) < _minPriceUpdate)
                    {
                        log(String.Format("DEBUG: BUY price {0:0.00000} too similar, using previous", buyPrice));
                        return _buyOrderPrice;
                    }

                    if (buyPrice > _maxBuyPrice)
                    {
                        return _maxBuyPrice;
                    }
                    return buyPrice;
                }
            }

            //Order book filled with junk. Use order before last, so we see it in chart
            double price = bids.Last().Price + increment;
            if (-1 != _buyOrderId && Math.Abs(price - _buyOrderPrice) < _minPriceUpdate)
            {
                return _buyOrderPrice;
            }
            return Math.Round(price, DEC_PLACES);
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:46,代码来源:DirectArbitrage.cs

示例7: runningSelloff

        /// <summary>There's a dump on market, best time to SELL.</summary>
        private static bool runningSelloff(List<TradeResponse> tradeHistory)
        {
            //There's lot of activity in recent time and price is falling
            const double PRICE_DIFF = 3 * 0.001;  //0.3%

            var endTime = tradeHistory.Last().TimeTyped;
            var startTime = endTime.AddSeconds(-90);    //Trades of past 90 seconds
            var pastTrades = tradeHistory.Where(trade => trade.TimeTyped >= startTime).ToList();
            if (pastTrades.Count < 10)        //TODO: tune up
                return false;

            var startPrice = pastTrades.First().price;
            var endPrice = pastTrades.Last().price;
            return (startPrice > endPrice && startPrice - endPrice >= startPrice * PRICE_DIFF);
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:16,代码来源:MarketTrend.cs

示例8: suggestPrice

        private double suggestPrice(List<FiatAsk> asks, double minPrice, double maxPrice, int currentOrderId, double currentOrderPrice, double minPriceUpdate)
        {
            if (null == asks || !asks.Any())
            {
                return currentOrderPrice > 0.0 ? currentOrderPrice : minPrice;
            }

            const int DEC_PLACES = 14;
            double increment = 2.0 * minPriceUpdate;

            //Find first ASK price higher than minPrice
            foreach (FiatAsk ask in asks)
            {
                //Don't consider own order
                if (_config.AccessKey == ask.Account && ask.Sequence == currentOrderId)
                {
                    continue;
                }

                if (ask.Price >= minPrice)
                {
                    double sellPrice = Math.Round(ask.Price - increment, DEC_PLACES);

                    //The difference is too small. Leave previous price to avoid server call
                    if (-1 != currentOrderId && Math.Abs(sellPrice - currentOrderPrice) < minPriceUpdate)
                    {
                        log(String.Format("DEBUG: price {0:0.00000} too similar, using previous", sellPrice));
                        return currentOrderPrice;
                    }

                    if (sellPrice > maxPrice)
                    {
                        return maxPrice;
                    }
                    return sellPrice;
                }
            }

            //Order book filled with junk. Use order before last, so we see it in chart
            double price = asks.Last().Price - increment;
            if (-1 != currentOrderId && Math.Abs(price - currentOrderPrice) < minPriceUpdate)
            {
                return currentOrderPrice;
            }
            if (price < minPrice)
            {
                return minPrice;
            }
            return Math.Round(price, DEC_PLACES);
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:50,代码来源:DirectArbitrage.cs

示例9: suggestSellPrice

        private double suggestSellPrice(List<MarketOrder> asks)
        {
            if (null == asks || !asks.Any())
            {
                return _sellOrderPrice > 0.0 ? _sellOrderPrice : _sellMinPrice;
            }

            const int DEC_PLACES = 14;
            double increment = 2.0 * _minPriceUpdate;

            //Find first ASK price higher than minPrice
            foreach (MarketOrder ask in asks)
            {
                //Don't consider own order
                if (ask.Amount.eq(_sellOrderAmount) && ask.Price.eq(_sellOrderPrice))
                {
                    continue;
                }

                if (ask.Price >= _sellMinPrice)
                {
                    double sellPrice = Math.Round(ask.Price - increment, DEC_PLACES);

                    //The difference is too small. Leave previous price to avoid server call
                    if (-1 != _sellOrderId && Math.Abs(sellPrice - _sellOrderPrice) < _minPriceUpdate)
                    {
                        log($"DEBUG: price {sellPrice:0.#####} too similar, using previous");
                        return _sellOrderPrice;
                    }

                    if (sellPrice > _sellMaxPrice)
                    {
                        return _sellMaxPrice;
                    }
                    return sellPrice;
                }
            }

            //Order book filled with junk. Use order before last, so we see it in order book
            double price = asks.Last().Price - increment;
            if (-1 != _sellOrderId && Math.Abs(price - _sellOrderPrice) < _minPriceUpdate)
            {
                return _sellOrderPrice;
            }
            if (price < _sellMinPrice)
            {
                return _sellMinPrice;
            }
            return Math.Round(price, DEC_PLACES);
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:50,代码来源:ArbitrageTrader.cs

示例10: suggestBuyPrice

        private double suggestBuyPrice(List<MarketOrder> bids)
        {
            if (null == bids || !bids.Any())
            {
                return _buyOrderPrice > 0.0 ? _buyOrderPrice : _buyMaxPrice;
            }

            const int DEC_PLACES = 14;
            double increment = 2.0 * _minPriceUpdate;

            //Find first BID price lower than maxPrice
            foreach (MarketOrder bid in bids)
            {
                //Don't consider own order
                if (bid.Amount.eq(_buyOrderAmount) && bid.Price.eq(_buyOrderPrice))
                {
                    continue;
                }

                if (bid.Price <= _buyMaxPrice)
                {
                    double buyPrice = Math.Round(bid.Price + increment, DEC_PLACES);

                    //The difference is too small. Leave previous buy price to avoid server call
                    if (-1 != _buyOrderId && Math.Abs(buyPrice - _buyOrderPrice) < _minPriceUpdate)
                    {
                        log($"DEBUG: price {buyPrice:0.#####} too similar, using previous");
                        return _buyOrderPrice;
                    }

                    if (buyPrice < _buyMinPrice)
                    {
                        return _buyMinPrice;
                    }
                    return buyPrice;
                }
            }

            //Order book filled with junk. Use order before last, so we see it in order book
            double price = bids.Last().Price + increment;
            if (-1 != _buyOrderId && Math.Abs(price - _buyOrderPrice) < _minPriceUpdate)
            {
                return _buyOrderPrice;
            }
            if (price > _buyMaxPrice)
            {
                return _buyMaxPrice;
            }
            return Math.Round(price, DEC_PLACES);
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:50,代码来源:ArbitrageTrader.cs

示例11: isRising

        private bool isRising(List<Candle> candles)
        {
            const int MIN_CANDLES = 3;

            if (candles.Count < MIN_CANDLES)
                return false;
            candles = candles.TakeLast(MIN_CANDLES).ToList();

            //Present candle is significant rise
            if (candles.Last().ClosingPrice > candles.Last().OpeningPrice + 3.0*PRICE_SIGNIFICANCE_LIMIT)
                return true;

            //Previous 2 candles were rises and latest price was rise too //TODO: maybe something more sofisticated
            return candles[0].ClosingPrice > candles[0].OpeningPrice + PRICE_SIGNIFICANCE_LIMIT &&
                   candles[1].ClosingPrice > candles[1].OpeningPrice + PRICE_SIGNIFICANCE_LIMIT &&
                   candles[1].ClosingPrice < candles.Last().ClosingPrice;   //Most recent price decides
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:17,代码来源:MarketTrend.cs


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