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


C# List.RemoveAt方法代码示例

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


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

示例1: ReadLine

        public override string ReadLine()
        {
            if (stream.Position == stream.Length)
            {
                return null;
            }

            var byteList = new List<int>();
            while (stream.Position != stream.Length)
            {
                int b = stream.ReadByte();
                if (b == (int)'\n')
                {
                    break;
                }
                else
                {
                    byteList.Add(b);
                }
            }
            while (byteList[byteList.Count - 1] == (int)'\r')
            {
                byteList.RemoveAt(byteList.Count - 1);
            }
            return Encoding.UTF8.GetString(byteList.Select(value => (byte)value).ToArray());
        }
开发者ID:KalitaAlexey,项目名称:axxon_soft_test_task,代码行数:26,代码来源:UnbufferedStreamReader.cs

示例2: Process

        /// <summary>
        /// Region growing to encode the source image data.
        /// </summary>
        /// <param name="locationPool"></param>
        /// <param name="maximumDistance"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private static HashSet<Region> Process(LocationPool locationPool, double maximumDistance, RegionType type)
        {
            HashSet<Region> result = new HashSet<Region>();
            List<Location> todoList = new List<Location>();
            //let's process pixels into regions
            Region region = null;

            HashSet<Location> alreadyChecked = new HashSet<Location>();

            while (!locationPool.Empty())
            {
                alreadyChecked.Clear();
                Location seed = locationPool.RandomLocation();
                //Console.WriteLine("Have seed " + seed);
                if (type == RegionType.MonoRegion)
                {
                    region = new MonoRegion();
                }
                else if (type == RegionType.MultiColorRegion)
                {
                    MultiColorRegion multiColorRegion = new MultiColorRegion(maximumDistance);
                    region = multiColorRegion;
                }

                region.Add(seed);
                region.Origin = seed.Point;
                seed.Region = region;
                locationPool.SetMarked(seed);
                alreadyChecked.Add(seed);

                AddNeighbors(seed, todoList, alreadyChecked);
                todoList.Sort((x, y) => (int)(SxzColor.GetColorDistance(seed.Color, x.Color) - SxzColor.GetColorDistance(seed.Color, y.Color)));

                int sortCounter = 0;

                //inner loop
                while (todoList.Count != 0)
                {
                    //Console.WriteLine("Unmarked total " + locationPool.Unmarked.Count + " and todolist total " + todoList.Count);
                    seed = todoList[0];
                    todoList.RemoveAt(0);
                    sortCounter++;

                    if (seed.Marked)
                    {
                        throw new Exception("Location already marked!");
                    }

                    if (!region.IsValid(seed))
                    {
                        //we can process non-adjacent pixels by adding neighbors here and sorting before returning but limit the distance from an already
                        //validated location
                        continue;
                    }

                    //Console.WriteLine("Parsed pixel " + seed);
                    //we have a winner!
                    region.Add(seed);
                    locationPool.SetMarked(seed);

                    AddNeighbors(seed, todoList, alreadyChecked);
                    //if (todoList.Count < 1000)
                    if (todoList.Count < 1000 || sortCounter > 1000)
                    {
                        //let's limit the number to be sorted for performance sake
                        todoList.Sort((x1, y1) => (int)(SxzColor.GetColorDistance(seed.Color, x1.Color) - SxzColor.GetColorDistance(seed.Color, y1.Color)));
                        sortCounter = 0;
                    }
                }

                result.Add(region);
            }

            return result;
        }
开发者ID:neuroradiology,项目名称:Sxz,代码行数:82,代码来源:ParseImage.cs

示例3: DeAuthorize

 public static bool DeAuthorize(AuthData data)
 {
     Keys keys = GetKeys();
     if (keys != null && keys.Public.Equals(data.PublicKey))
     {
         var privateKey = keys.Private;
         var hashCheck = General.Sha1Hash(data.Data + privateKey + data.PublicKey);
         if (hashCheck.Equals(data.Hash))
         {
             var computersJsonFile = GetFile("~/App_Data/", "computers.json");
             var computers = new List<ComputerData>();
             try
             {
                 computers = JsonConvert.DeserializeObject<List<ComputerData>>(GetFileContents(computersJsonFile));
             }
             catch { }
             var computerData = new ComputerData()
             {
                 Name = data.HostName,
                 IpExternal = data.IpExternal,
                 IpInternal = data.IpInternal,
                 LastActive = DateTime.Now,
                 FileUploaded = null,
                 BytesUploaded = 0,
                 Hash = null
             };
             computerData.Hash = Transmitter.GetComputerHash(computerData);
             var computer = computers.Find(x => x.Hash == computerData.Hash);
             if (computer != null)
             {
                 computers.RemoveAt(computers.IndexOf(computer));
                 var computersJson = JsonConvert.SerializeObject(computers);
                 System.Threading.Thread.Sleep(250);
                 File.WriteAllText(computersJsonFile, computersJson);
             }
             return true;
         }
     }
     return false;
 }
开发者ID:rasadeyan,项目名称:RestlessHoneySeeker,代码行数:40,代码来源:RhsApi.cs


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