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


C# ICollection.Last方法代码示例

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


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

示例1: AppendMigrationInfo

 private void AppendMigrationInfo(ICollection<long> appliedMigrations)
 {
     Status.AppendDetailsLine("Migration successful. ");
     if (appliedMigrations == null || appliedMigrations.Count < 1)
     {
         Status.AppendDetailsLine("No migrations to run.");
         return;
     }
     var lastAppliedMigration = appliedMigrations.Last();
     Status.AppendDetailsLine("Last applied migration version: " + lastAppliedMigration);
 }
开发者ID:pedershk,项目名称:dotnetprograms,代码行数:11,代码来源:MigrateDatabaseStep.cs

示例2: GaugeStatSummary

 public GaugeStatSummary(ICollection<GaugeStat> stats, DateTime start, DateTime end) {
     Stats = stats;
     Count = Stats.Sum(s => s.Count);
     Total = Stats.Sum(s => s.Total);
     Last = Stats.Last().Last;
     Min = Stats.Min(s => s.Min);
     Max = Stats.Max(s => s.Max);
     StartTime = start;
     EndTime = end;
     Average = Count > 0 ? Total / Count : 0;
 }
开发者ID:geffzhang,项目名称:Foundatio,代码行数:11,代码来源:GaugeStat.cs

示例3: Hotkey

 public Hotkey(string name, ICollection<KeyCode> defaultKey)
 {
     _name = name;
     if (defaultKey.Count == 0)
     {
         Tools.LogWf("No keys for hotkey {0}. Need at least 1 key in defaultKey parameter, got none.", _name);
     }
     else
     {
         _trigger = defaultKey.Last();
         SetModifiers(defaultKey.SkipLast().ToList());
     }
     Load();
 }
开发者ID:Biotronic,项目名称:StripSymmetry,代码行数:14,代码来源:Hotkey.cs

示例4: Solve

        private static DenseMatrix Solve(DenseMatrix matrix, ICollection<int> vectorJ, int n)
        {
            var matrixC = DenseMatrix.CreateIdentity(n);
            var matrixB = DenseMatrix.CreateIdentity(n);
            DenseMatrix matrixE = DenseMatrix.CreateIdentity(n);
            var vectorSk = new int[n];

            for (var i = 0; i < n; i++)
            {
                var k = 0;

                //step 1
                foreach (var j in vectorJ)
                {
                    double alphaJ = Math.Abs(matrixE.Column(i) * matrixB * matrix.Column(j));

                    // get a first no zero alpha
                    if (ZeroComparer.IsBiggerThanZero(alphaJ))
                    {
                        k = j;
                        vectorSk[j] = i;
                        break;
                    }

                    // determinant is zero
                    if (j == vectorJ.Last())
                    {
                        return null;
                    }
                }

                // step 2
                vectorJ.Remove(k);
                matrixC.SetColumn(i, matrix.Column(k));

                var z = matrixB * matrixC.Column(i);
                var zk = z[i];
                z[i] = -1;
                var d = -1 / zk * z;
                var matrixD = DenseMatrix.CreateIdentity(n);
                matrixD.SetColumn(i, d);

                matrixB = matrixD * matrixB;
            }

            var listOfRows = vectorSk.Select(d => matrixB.Row(d)).ToList();

            return DenseMatrix.OfRowVectors(listOfRows);
        }
开发者ID:VolAnder123,项目名称:MOIULabs,代码行数:49,代码来源:InverseMatrix.cs

示例5: Encode

        public EncodingResult Encode(
                ICollection<string> codePaths, IEnumerable<CstNode> allCsts,
                LearningExperiment oracle, SeedNodeSet seedNodeSet = null) {
            var fileName = codePaths.Count > 0
                    ? string.Join(",", codePaths).GetHashCode() + "_" +
                      (codePaths.First() + "," + codePaths.Last() + ",").GetHashCode() + "_"
                      + codePaths.Count + ".encoded"
                    : null;
            var formatter = new BinaryFormatter();
            if (fileName != null && File.Exists(fileName)) {
                using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) {
                    try {
                        var ret = ((EncodingResult)formatter.Deserialize(fs)).MakeImmutable();
                        Console.WriteLine("############### Warning ###############");
                        Console.WriteLine("Cache file of encoded result is used.");
                        Console.WriteLine("#######################################");
                        return ret;
                    } catch (Exception e) {
                        Console.Error.WriteLine(e);
                    }
                }
            }

            var allUppermostNodes = allCsts.SelectMany(
                    cst => LearningExperimentUtil.GetUppermostNodesByNames(cst, _selectedNodeNames));

            var result = new EncodingResult();
            if (seedNodeSet != null) {
                result.SeedAcceptedNodeCount = seedNodeSet.AcceptedNodes.Count;
                result.SeedNodeCount = result.SeedAcceptedNodeCount
                                       + seedNodeSet.RejectedNodes.Count;
                EncodeSeedNodes(
                        seedNodeSet.AcceptedNodes, result, result.IdealAcceptedVector2GroupPath,
                        result.SeedAcceptedVector2GroupPath, oracle);
                EncodeSeedNodes(
                        seedNodeSet.RejectedNodes, result, result.IdealRejectedVector2GroupPath,
                        result.SeedRejectedVector2GroupPath, oracle);
            }
            EncodeTargetNodes(allUppermostNodes, result, oracle);

            if (fileName != null) {
                using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) {
                    formatter.Serialize(fs, result);
                }
            }
            return result.MakeImmutable();
        }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:47,代码来源:FeatureEncoder.cs

示例6: ForgotYourPassword

        public ActionResult ForgotYourPassword(ICollection<object> credentials)
        {
            if (credentials.Count == 2)
            {
                string username = credentials.First().ToString();
                string email = credentials.Last().ToString();

                if (!string.IsNullOrEmpty(username) || !string.IsNullOrEmpty(email))
                {
                    //Search for user.
                    var user = WAFContext.Engine.SystemSession.GetContents<SystemUser>().Where(u => u.UserName == username && u.Email == email);

                    if (user.Count() > 0)
                    {
                        SystemUser systemUser = (SystemUser)user.First();

                        //Reset password and update
                        string newPassword = systemUser.Password.GenerateAndSetNew();
                        systemUser.UpdateChanges();

                        //Generate mail content
                        string body = "User : " + systemUser.UserName + " Passordet ditt har blitt resatt til: " + newPassword;
                        string to = systemUser.Email;
                        if (to == "")
                        {
                            to = "[email protected]";
                        }
                        string from = "[email protected]";
                        string subject = "Password reset";
                        //Send mail
                        WAFContext.Session.SendEmail(true, body, to, from, subject);
                        TempData.Add("success", "E-post har blitt sent ut til deg på " + to);
                        return Redirect("/");
                    }
                    else
                    {
                        //TempData.Add("error", "Feil brukernavn eller e-post");
                        return Redirect("/");
                        //return Redirect("/Page/ForgotYourPassword");
                    }

                }
            }
            TempData.Add("error", "Fyll inn brukernavn og e-post");
            // return Redirect("/Page/ForgotYourPassword");
            return Redirect("/");
        }
开发者ID:kyvkri,项目名称:MG,代码行数:47,代码来源:AccountController.cs

示例7: ValidateUser

        public ActionResult ValidateUser(ICollection<object> credentials)
        {
            string returnurl = "/";

            if (credentials.Count == 2)
            {
                string username = credentials.First().ToString();
                string password = credentials.Last().ToString();

                if (username != "" && password != "")
                {

                    if (Membership.ValidateUser(username, password))
                    {
                        FormsAuthentication.SetAuthCookie(username, false);

                        WAFContext.LogInView(username);

                        TempData["Result"] = "Velkommen " + username;
                        UserMG user = (UserMG)WAFContext.Engine.SystemSession.GetContents<UserMG>().Where(u => u.UserName == username).First();
                        returnurl = WAFContext.GetUrl(MgHelper.MyWishListsPage);
                    }
                    else
                    {

                        //MembershipUser user = Membership.GetUser(username);
                        //if (user != null)
                        //{
                        //    //User exists
                        //    if (!user.IsApproved)
                        //    {
                        //        //Account Unapproved
                        //        TempData["Result"] = "Your account is not approved.";
                        //    }
                        //    else if (user.IsLockedOut)
                        //    {
                        //        //Account Locked
                        //        TempData["Result"] = "Your account is locked.";
                        //    }
                        //    else
                        //    {
                        //        //Invalid username or password
                        //        TempData["Result"] = "Invalid username or password.";
                        //    }
                        //}
                        //else
                        //{
                        TempData["Result"] = "Ugyldig brukernavn eller passord";
                        //}
                    }
                }
                else
                {
                    TempData["Result"] = "Verdi mangler";
                }
            }
            return Redirect(returnurl);
        }
开发者ID:kyvkri,项目名称:MG,代码行数:58,代码来源:AccountController.cs

示例8: WritePages

        void WritePages(ICollection<Page> pages, long startPageIndex)
        {
            var buffer = new byte[pages.Count * PageSize];

            using (var ms = new MemoryStream(buffer))
            {
                foreach (var pageBuffer in pages.Select(page => page.GetBuffer()))
                    ms.Write(pageBuffer, 0, pageBuffer.Length);

                ms.Seek(0, SeekOrigin.Begin);
                var offset = startPageIndex * PageSize;
                _blob.WritePages(ms, offset);
            }

            _cachedPage = pages.Last();
            _cachedPageIndex = startPageIndex + pages.Count - 1;
        }
开发者ID:higheredgrowth,项目名称:lokad-cqrs,代码行数:17,代码来源:PageBlobAppendStream.cs

示例9: CountChangeIter

 private static int CountChangeIter(double x, ICollection<double> changes)
 {
     var n = changes.Count;
     if (n == 0)
     {
         return 0;
     }
     var minChange = changes.Last();
     if (System.Math.Abs(x - minChange) <= 1e-5)
     {
         return 1;
     }
     if (x < minChange)
     {
         return 0;
     }
     return CountChangeIter(x - minChange, changes) + CountChangeIter(x, changes.Take(n - 1).ToList());
 }
开发者ID:ccpromise,项目名称:Code-Log,代码行数:18,代码来源:PuzzleBefore.cs

示例10: ConvertNegativeLongs

            private static byte[] ConvertNegativeLongs(ICollection<byte> output, long value)
            {
                if (value >= sbyte.MinValue)
                    return new[] { output.Last() };

                if (value >= -32768)
                    return output.Skip(output.Count - 2).ToArray();

                if (value >= -2147483648)
                    return output.Skip(output.Count - 4).ToArray();

                return output.ToArray();
            }
开发者ID:cskardon,项目名称:PackStream.NET,代码行数:13,代码来源:IntPacker.cs

示例11: FixEqualLaneAmount

        public static List<Round> FixEqualLaneAmount(ICollection<Round> toFix, ICollection<Lane> Lanes)
        {
            //Skapa kö för att loopa alla rundor
            var theQueue = new Queue<Round>(toFix);
            //Slutresultatet som skall returnas
            var Result = new List<Round>();
            //Nuvarande spelrad
            var CurrentRow = new List<Round>();
            //Lista som håller koll på vilka behov som finns på raden
            var RowTeamLanes = new List<TeamLane>();

            //Loopa igenom alla rundor
            while (theQueue.Count > 0)
            {
                //Hämta ny rad
                CurrentRow = new List<Round>(); //Nollställ listan
                RowTeamLanes = new List<TeamLane>(); //Nollställ listan
                for (int i = 0; i < (theQueue.Count > Lanes.Count ? Lanes.Count : theQueue.Count); i++) //Loopa igenom rundorna på raden
                {
                    CurrentRow.Add(theQueue.Dequeue()); //Lägg till rundan i raden
                }

                //Generera alla teamlanes
                foreach (var item in Lanes) //Loopa igenom banorna
                {
                    foreach (var R in CurrentRow) //Loopa igenom alla rundor på raden
                    {
                        RowTeamLanes.Add(R.GetLaneCount(Result, item)); //Lägg till behovet i listan
                    }

                }

                //Rangordna listan efter behov (Kanske går åt fel håll!!!!)
                RowTeamLanes = RowTeamLanes.OrderBy(t => t.Count).ToList();
                var newRow = new List<Round>();
                //Filtrera ut rätt ordning enligt behov
                while (RowTeamLanes.Count > 0)
                {
                    var toAdd = RowTeamLanes[0];
                    toAdd.Round.Lane = toAdd.Lane;
                    var toLoop = RowTeamLanes.Where(r => r.Round == toAdd.Round || r.Lane == toAdd.Lane).ToList();
                    foreach (var item in toLoop)
                    {
                        RowTeamLanes.Remove(item);
                    }
                    newRow.Add(toAdd.Round);
                    RowTeamLanes.Remove(toAdd);
                }

                //Lägg till rätt ordning i resultatet
                foreach (var item in Lanes)
                {
                    foreach (var r in newRow.Where(r => r.Lane == item).ToList())
                    {
                        Result.Add(r);
                    }

                }
            }
            var counter = 1;
            foreach (var item in Result)
            {
                item.PlayOrder = counter;
                counter++;
            }
            if (Result.Last().Game.Teams.Count == 8 && Lanes.Count == 2)
            {
                Result.Last().Lane = Lanes.Last();
            }
            return Result;
        }
开发者ID:Capplequoppe,项目名称:CurlerOnline,代码行数:71,代码来源:Utilities.cs

示例12: HandleSingleWordSurnamePrefix

		private static void HandleSingleWordSurnamePrefix(NameParts result, ICollection<string> parts)
		{
			var indexOfPrefix = IndexOfAnyCaseInsensitive(parts, SingleWordNamePrefixes);
			if (indexOfPrefix != parts.Count - 1)
			{
				return;
			}

			result.Surname = parts.Last() + " " + result.Surname;
			result.MiddleName = parts.Count == 1 ? null : String.Join(" ", parts.Take(parts.Count - 1));
		}
开发者ID:maxshenfield,项目名称:NameParsing,代码行数:11,代码来源:StringExtensions.cs

示例13: HandleSingleWordSurnamePrefixGivenAMiddleNameExists

		private static void HandleSingleWordSurnamePrefixGivenAMiddleNameExists(NameParts result, ICollection<string> parts)
		{
			if (parts.Count < 2)
			{
				return;
			}
			var indexOfPrefix = IndexOfAnyCaseInsensitive(parts, "o");
			if (indexOfPrefix != parts.Count - 1 ||
				result.Surname.StartsWith("o", StringComparison.OrdinalIgnoreCase))
			{
				return;
			}

			result.Surname = parts.Last() + " " + result.Surname;
			result.MiddleName = parts.Count == 1 ? null : String.Join(" ", parts.Take(parts.Count - 1));
		}
开发者ID:maxshenfield,项目名称:NameParsing,代码行数:16,代码来源:StringExtensions.cs

示例14: IsVanXSurnamePrefix

		private static bool IsVanXSurnamePrefix(ICollection<string> parts)
		{
			var indexOfDe = IndexOfCaseInsensitive(parts, "van");
			if (indexOfDe < 0 || indexOfDe != parts.Count - 2)
			{
				return false;
			}

			var lastLower = parts.Last().ToLower();
			if (!new[] { "de", "den", "der" }.Contains(lastLower))
			{
				return false;
			}
			return true;
		}
开发者ID:maxshenfield,项目名称:NameParsing,代码行数:15,代码来源:StringExtensions.cs

示例15: UseRememberedTrackFrom

 private void UseRememberedTrackFrom(ICollection<ITrack> tracks)
 {
     CurrentTrack = tracks.Last();
     tracks.Remove(CurrentTrack);
 }
开发者ID:kfazi,项目名称:SpotifyHeadlessPlayer,代码行数:5,代码来源:MemorizedPlaylistPlayStrategy.cs


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