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


C# SortedSet.Select方法代码示例

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


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

示例1: GenerateUsingDirectives

		internal static SyntaxList<UsingDirectiveSyntax> GenerateUsingDirectives(
			this SyntaxNode @this, SemanticModel model)
		{
			var namespacesForType = new SortedSet<string>();

			foreach (var childNode in @this.DescendantNodes(_ => true))
			{
				var symbol = model.GetSymbolInfo(childNode).Symbol;

				if (symbol != null && symbol.Kind != SymbolKind.Namespace &&
					symbol.ContainingNamespace != null)
				{
					if ((symbol as ITypeSymbol)?.SpecialType ==
						SpecialType.System_Void)
					{
						continue;
					}

					var containingNamespace = symbol.GetContainingNamespace();

					if (!string.IsNullOrWhiteSpace(containingNamespace))
					{
						namespacesForType.Add(containingNamespace);
					}
				}
			}

			return SyntaxFactory.List(
				namespacesForType.Select(_ => SyntaxFactory.UsingDirective(
					SyntaxFactory.IdentifierName(_))));
		}
开发者ID:JasonBock,项目名称:CompilerAPIBook,代码行数:31,代码来源:SyntaxNodeExtensions.cs

示例2: AssertOrderedNodeNames

        protected void AssertOrderedNodeNames(String[] names, String[] expected)
        {
            Assert.AreEqual(names.Length, expected.Length, "The two arrays should be the same size!");
            var nodeNames = new SortedSet<ZNodeName>();
            foreach (string name in names)
            {
                nodeNames.Add(new ZNodeName(name));
            }

            int index = 0;
            foreach (string name in nodeNames.Select(nodeName => nodeName.Name))
            {
                Assert.AreEqual(name, expected[index++]);
            }
        }
开发者ID:chriseldredge,项目名称:zookeeper,代码行数:15,代码来源:ZNodeNameTests.cs

示例3: MakeAllPossibleWaysRec

        private IEnumerable<PrimaryFrameNode> MakeAllPossibleWaysRec(List<string> processed, ProjectionElement element, SortedSet<BoundingParameter> orderedParameters, int depth)
        {
            if (depth == int.MinValue)
                throw new InvalidOperationException("Ошибка при построении плана - слишком глубокая схема для разбора");
            if (depth == 0)
                return new PrimaryFrameNode[0];

            #region Проверка - был ли проверен текущий элемент, и добавление его к проверенным

            var hash = GetHashForElementAndParameters(element, new ParameterNames(orderedParameters.Select(k => k.Name)));

           
                if (processed.Contains(hash))
                    return new PrimaryFrameNode[0];

                processed.Add(hash);
            

            #endregion

            #region Добавление текущего элемента к родительским параметрам или обнуление глубины уже существующего параметра с данным именем

            foreach (var p in orderedParameters)
            {
                p.Depth++;
            }

            var parameter = orderedParameters.FirstOrDefault(k => k.Name == element.Name);
            int oldDepth;
            if (parameter == null)
            {
                parameter = new BoundingParameter(element.Name, 1);
                orderedParameters.Add(parameter);
                oldDepth = 0;
            }
            else
            {
                oldDepth = parameter.Depth;
                parameter.Depth = 1;
            }

            #endregion

            #region Обход детей дочерних нод

            var childElements = element.DownRelations
                .Select(k => new
                                 {
                                     relation = k,
                                     k.ChildElement,
                                     children =
                                 MakeAllPossibleWaysRec(processed, k.ChildElement, orderedParameters, depth - 1)
                                 }).ToArray();

            #endregion



            processed.Remove(hash);

            if (oldDepth == 0)
                orderedParameters.Remove(parameter);
            else
            {
                parameter.Depth = oldDepth;
            }


            #region Формирование списка нод вместе с дочерними

            var allNodes = childElements.Select(k =>
                                                new PrimaryFrameNode
                                                    {
                                                        Current = k.ChildElement,
                                                        OrderedParameters =
                                                            orderedParameters.Where(k2=>!StringComparer.InvariantCultureIgnoreCase.Equals(k2.Name,element.Name))
                                                                             .Select(k2 => new BoundingParameter(k2.Name, k2.Depth))
                                                                             .ToArray(),
                                                        Parent = element,
                                                        Relation = k.relation
                                                    })
                .Concat(childElements.SelectMany(k => k.children))
                .ToArray();

            #endregion


            foreach (var p in orderedParameters)
            {
                p.Depth--;
            }
          
            return allNodes;
        }
开发者ID:kayanme,项目名称:Dataspace,代码行数:94,代码来源:FramingPlanBuilder.cs

示例4: RetrieveConflictingDependancyFromCacheOrResolve

        /// <summary>
        /// Try to retrieve dependancies from cache if it was already compute, if not try to resolve it
        /// </summary>
        internal Tuple<SemanticVersion, string> RetrieveConflictingDependancyFromCacheOrResolve(SortedDictionary<Tuple<SemanticVersion, string>, DllReference> assemblies,
                                                                                                DllReference parentAssembly, SortedSet<SemanticVersion> assembliesSemanticVersions,
                                                                                                AssemblyReference assemblyDependency)
        {
            var asmss = assembliesSemanticVersions
                .Select(_ =>
                {
                    try
                    {
                        return assemblies[new Tuple<SemanticVersion, string>(_, assemblyDependency.Item2)];
                    }
                    catch (KeyNotFoundException exc)
                    {
                        var excption = new VersionNotFoundException(String.Format("versions.ini is not consistent with assemblies.ini. versions.ini is referencing {1}-{0} while it doesn't exist in Assemblies.ini", _, assemblyDependency.Item2), exc);
                        throw excption;
                    }
                })
                //If Parent assembly is a snapshot we include snapshot in dependency otherwise no because nuget doesn't support
                // official package with snapshot dependency
                .Where(_ =>
                    (string.IsNullOrEmpty(parentAssembly.Id.Item1.SpecialVersion) &&
                        !string.IsNullOrEmpty(_.Id.Item1.SpecialVersion))
                        ? false
                        : true
                );

            var result = ResolveConflictingDependancy(asmss, parentAssembly);
            return result;
        }
开发者ID:Ullink,项目名称:NugetConverter,代码行数:32,代码来源:DependenciesResolverService.cs

示例5: GetSubPages

 public IEnumerable<WikiPage> GetSubPages(WikiPage page)
 {
     var links = new SortedSet<string>(this.syntax.GetLinks(page.Text));
     var pages = this.repository.Query().Where(p => links.Contains(p.Slug)).ToDictionary(p => p.Slug);
     return links.Select(link => pages[link]);
 }
开发者ID:ashmind,项目名称:lightwiki,代码行数:6,代码来源:LinkBasedHierarchyProvider.cs

示例6: AgenciesListView_SelectionChanged

 private async void AgenciesListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     LoadingRect.Visibility = Visibility.Visible;
     MainProgressRing.IsActive = true;
     var inOrder = (Func<RouteListing, RouteListing, bool>)delegate (RouteListing first, RouteListing second)
     {
         var splitName = (Func<string, Tuple<int, string>>)delegate (string name)
         {
             string num = new string(name.TakeWhile(chr => char.IsNumber(chr)).ToArray());
             if (num.Length == 0)
                 return new Tuple<int, string>(0, name);
             else
                 return new Tuple<int, string>(int.Parse(num), name.Replace(num, ""));
         };
         var splitFirst = splitName(first.Name);
         var splitSecond = splitName(second.Name);
         if (splitFirst.Item1 < splitSecond.Item1)
             return true;
         else if (splitFirst.Item1 > splitSecond.Item1)
             return false;
         else
             return string.Compare(splitFirst.Item2, splitSecond.Item2, StringComparison.CurrentCultureIgnoreCase) < 0;
     };
     MainList.Items.Clear();
     var agency = (TransitAgency)AgenciesListView.SelectedItem;
     SortedSet<RouteListing> routesList = new SortedSet<RouteListing>(Comparer<RouteListing>.Create(new Comparison<RouteListing>((rt1, rt2) => inOrder(rt1, rt2) ? -1 : 1)));
     var routes = await Data.GetBusRoutesForAgency(agency.ID, new DataRetrievalOptions(DataSourceDescriptor.Cloud), MasterCancellationTokenSource.Token);
     RoutesWarning = routes.Item2.FinalSource != DataSourceDescriptor.Cloud;
     if (routes.Item1 != null)
     {
         foreach (var rte in routes.Item1)
         {
             var listing = new RouteListing(rte);
             await listing.RefreshIsDownloaded();
             routesList.Add(listing);
         }
         foreach (var rte in routesList)
             MainList.Items.Add(rte);
         await FileManager.SaveAgency(agency, routesList.Select(item => item.Route.ID).ToArray());
     }
     MainProgressRing.IsActive = false;
     LoadingRect.Visibility = Visibility.Collapsed;
 }
开发者ID:AlexKven,项目名称:OneAppAway-RTM,代码行数:43,代码来源:RoutesPage.xaml.cs

示例7: ComputeEncoding

        public string ComputeEncoding(FlowMatrix flowSpec, int maxSelWidth = 6)
        {
            var sb = new StringBuilder();
            sb.AppendLine("Control word encoding report");
            sb.AppendFormat("  Number of c-steps: {0}", flowSpec.NumCSteps);
            sb.AppendLine();
            sb.AppendFormat("  Maximum LUT inputs: {0}", maxSelWidth);
            sb.AppendLine();

            FlowSpec = flowSpec;

            var flowMap = new Dictionary<SignalRef, List<Flow>>();

            var neutralFlow = flowSpec.NeutralFlow;
            _vcf.AddFlow(neutralFlow);
            for (int i = 0; i < flowSpec.NumCSteps; i++)
            {
                var pflow = flowSpec.GetFlow(i);
                var nflow = new ParFlow(neutralFlow);
                nflow.Integrate(pflow);
                _vcf.AddFlow(nflow);
                foreach (var flow in nflow.Flows)
                {
                    List<Flow> flows;
                    if (!flowMap.TryGetValue(flow.Target, out flows))
                    {
                        flows = new List<Flow>();
                        flowMap[flow.Target] = flows;
                    }
                    flows.Add(flow);
                }
            }
            _vcf.Encode();
            var startTime = DateTime.Now;

            var encFlows = flowMap.Values
                .Select((l, i) => new EncodedFlow(l, i)).ToArray();
            var uncompressedMuxBits = encFlows.Sum(ef => MathExt.CeilLog2(ef.NumSymbols));
            sb.AppendFormat("  Uncompressed CW: {0} MUX bits + {1} value bits",
                uncompressedMuxBits, _vcf.GetUncompressedValueWordWidth());
            sb.AppendLine();

            int numTargets = encFlows.Length;
            var mergeCandidates = new List<Tuple<int, int, MergedFlow>>();
            var indices = new SortedSet<int>(Enumerable.Range(0, numTargets));
            var curGen = (EncodedFlow[])encFlows.Clone();
            bool mergedAny;
            var nextCandidates = new List<Tuple<int, int, MergedFlow>>();

            do
            {
                foreach (int i in indices)
                {
                    if (curGen[i].NumSymbols <= 1)
                        continue;

                    var upview = indices.GetViewBetween(i + 1, numTargets);
                    foreach (int j in upview)
                    {
                        if (curGen[j].NumSymbols <= 1)
                            continue;

                        var mergedFlow = new MergedFlow(curGen[i], curGen[j]);
                        mergeCandidates.Add(Tuple.Create(i, j, mergedFlow));
                    }
                }

                var orderedMergeCandidates = mergeCandidates.OrderByDescending(t => t.Item3.Score);
                var nextGen = (EncodedFlow[])curGen.Clone();
                var mergedIndices = new HashSet<int>();
                var mergedLowIndices = new SortedSet<int>();
                var mergedHiIndices = new HashSet<int>();
                mergedAny = false;
                foreach (var tup in orderedMergeCandidates)
                {
                    Debug.Assert(tup.Item2 > tup.Item1);

                    var mergedFlow = tup.Item3;
                    if (mergedFlow.Score == 0.0)
                        break;

                    int selWidth = MathExt.CeilLog2(mergedFlow.NumSymbols);
                    if (selWidth > maxSelWidth)
                        continue;

                    if (mergedIndices.Contains(tup.Item1) ||
                        mergedIndices.Contains(tup.Item2))
                        continue;

                    mergedIndices.Add(tup.Item1);
                    mergedIndices.Add(tup.Item2);
                    mergedLowIndices.Add(tup.Item1);
                    mergedHiIndices.Add(tup.Item2);
                    indices.Remove(tup.Item2);

                    mergedFlow.Realize();
                    Debug.Assert(nextGen[tup.Item1].Targets.All(t => mergedFlow.Targets.Contains(t)));
                    Debug.Assert(nextGen[tup.Item2].Targets.All(t => mergedFlow.Targets.Contains(t)));
                    nextGen[tup.Item1] = mergedFlow;
                    mergedAny = true;
//.........这里部分代码省略.........
开发者ID:venusdharan,项目名称:systemsharp,代码行数:101,代码来源:MicrocodeDesign.cs

示例8: CalculateFeatures

        private void CalculateFeatures()
        {
            backgroundWorker.ReportProgress(0, "First generating binned random palettes...checking for existing file");

            PaletteExtractor extractor = new PaletteExtractor(trainInDir, weightsDir, json);

            Dictionary<String, List<PaletteData>> palettes = LoadFilePalettes(trainReference.Path);
            if (trainReference.Filter)
            {
                var keys = palettes.Keys.ToArray<String>();
                foreach (String key in keys)
                    palettes[key] = removeOutliers(palettes[key]);
            }

            SaveRandomPalettes(Path.Combine(trainOutDir, "random-binned.tsv"), palettes, extractor);
            Dictionary<String, List<PaletteData>> randomP = LoadFilePalettes(Path.Combine(trainOutDir, "random-binned.tsv"));

            ClearLog(Path.Combine(trainOutDir, "timelog.txt"));

            Features[] included = Enum.GetValues(typeof(Features)).Cast<Features>().ToArray<Features>();

            SortedSet<Features> headers = new SortedSet<Features>(included);
            String saliencyPattern = "_Judd";
            String imageNameFile = Path.Combine(trainOutDir, "imageNames.txt");
            String outFile = Path.Combine(trainOutDir, "features.csv");

            File.WriteAllText(outFile, ""); //clear the file
            File.WriteAllText(imageNameFile, "");

            //write the headings in a separate file
            File.WriteAllText(Path.Combine(trainOutDir, "featurenames.txt"), String.Join("\n", headers.Select<Features, String>((a) => featureName.Name(a))));
            String log = Path.Combine(trainOutDir,"log.txt");
            Log(log, "Start");

            backgroundWorker.ReportProgress(0, "Calculating features...");
            int progress = 0;
            foreach (String key in palettes.Keys)
            {
                List<String> sources = new List<String>();
                List<String> allFeatures = new List<String>();
                List<double> scores = new List<double>();

                List<double> tempScores = new List<double>();
                double maxScore = Double.NegativeInfinity;
                double minScore = Double.PositiveInfinity;

                List<PaletteData> all = new List<PaletteData>(palettes[key]);
                foreach (PaletteData r in randomP[key])
                    all.Add(r);

                FeatureParams fp = extractor.SetupFeatureParams(headers, key, saliencyPattern, debug);

                foreach (PaletteData data in all)
                {
                    //calculate the score
                    double rep = 1 - GetAvgDist(new List<PaletteData>{data}, palettes[key]);

                    tempScores.Add(rep);
                    maxScore = Math.Max(rep, maxScore);
                    minScore = Math.Min(rep, minScore);

                    Dictionary<Features, double> features = extractor.CalculateFeatures(data, fp);

                    List<String> featureString = new List<String>();
                    foreach (Features f in headers)
                        featureString.Add(features[f].ToString());
                    allFeatures.Add(String.Join(",", featureString.ToArray<String>()));
                    sources.Add(data.id.ToString());
                }

                //normalize the scores
                foreach (double score in tempScores)
                    scores.Add((score - minScore) / (maxScore - minScore));

                List<String> outLines = new List<String>();
                //write the scores thus far
                for (int i = 0; i < scores.Count(); i++)
                {
                    outLines.Add(sources[i] + "," + scores[i] + "," + allFeatures[i]);
                }
                File.AppendAllLines(outFile, outLines.ToArray<String>());

                Log(log, key + " - " + DateTime.Now.ToString() + "\n");
                File.AppendAllText(imageNameFile, key + "\n");

                progress++;
                backgroundWorker.ReportProgress(100*progress/palettes.Keys.Count(), String.Format("Calculated features for {0} ({1}/{2})",key,progress,palettes.Keys.Count()));
            }
        }
开发者ID:brightown,项目名称:color-themes,代码行数:89,代码来源:Extract.cs


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