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


C# Tuple.ToLookup方法代码示例

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


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

示例1: DrawBrainIOLinks3D

        private static Item3D[] DrawBrainIOLinks3D(Viewport3D viewport, Tuple<int, int>[] links, Item3D[] items1, Item3D[] items2, Color defaultColor, bool isRainbow)
        {
            const double THICKNESS = .025;

            if (!isRainbow)
            {
                var lines = links.Select(o => Tuple.Create(items1[o.Item1].Position.Value, items2[o.Item2].Position.Value));

                return new[]
                {
                    new Item3D(AddLines(viewport, lines, defaultColor, THICKNESS)),
                };
            }

            List<Item3D> retVal = new List<Item3D>();

            foreach (var byItem1 in links.ToLookup(o => o.Item1))
            {
                //Color color = UtilityWPF.GetRandomColor(150, 220);
                Color color = new ColorHSV(StaticRandom.NextDouble(360), 60, 100).ToRGB();

                var lines = byItem1.Select(o => Tuple.Create(items1[byItem1.Key].Position.Value, items2[o.Item2].Position.Value));

                retVal.Add(new Item3D(AddLines(viewport, lines, color, THICKNESS)));
            }

            return retVal.ToArray();
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:28,代码来源:BrainLinks.xaml.cs

示例2: SaveImages

        private static void SaveImages(string parentFolder, string childFolder, int width, int height, Tuple<string, double[]>[] images, bool isColor)
        {
            if (images == null || images.Length == 0)
            {
                return;
            }

            foreach (var set in images.ToLookup(o => o.Item1))
            {
                SaveImages(parentFolder, childFolder, width, height, set.Select(o => o.Item2).ToArray(), isColor, set.Key);
            }
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:12,代码来源:BrainRGBRecognizer.cs

示例3: AddLinks

        /// <summary>
        /// This adds 2s to 1s one at a time (specified by distances2to1_AddOrder)
        /// </summary>
        private static Tuple<int, int>[] AddLinks(LinkItem[] items1, LinkItem[] items2, DistributeDistances distances, IEnumerable<int> distances2to1_AddOrder, Tuple<int, int>[] initial = null)
        {
            // Store the inital link burdens
            BrainBurden[] links = Enumerable.Range(0, items1.Length).
                Select(o => new BrainBurden(o, items1, items2)).
                ToArray();

            if (initial != null)
            {
                #region Store initial

                foreach (var set in initial.ToLookup(o => o.Item1))
                {
                    foreach (int item2Index in set.Select(o => o.Item2))
                    {
                        links[set.Key].AddIOLink(item2Index);
                    }
                }

                #endregion
            }

            foreach (var distanceIO in distances2to1_AddOrder.Select(o => distances.Distances2to1[o]))
            {
                int ioIndex = distanceIO.Index2;
                int closestBrainIndex = distanceIO.DistancesTo1[0].Item1;

                AddIOLink(links, ioIndex, items2[ioIndex].Size, closestBrainIndex, distances.ResistancesItem1[closestBrainIndex]);
            }

            // Build the return
            List<Tuple<int, int>> retVal = new List<Tuple<int, int>>();
            foreach (BrainBurden burden in links)
            {
                retVal.AddRange(burden.IOLinks.Select(o => Tuple.Create(burden.Index, o)));
            }

            return retVal.ToArray();
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:42,代码来源:ItemLinker.cs


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