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


C# Set.Insert方法代码示例

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


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

示例1: UpdateFront

        void UpdateFront() {
            var newFrontEdges = new Set<CdtEdge>();
            foreach (var t in addedTriangles)
                foreach (var e in t.Edges)
                    if (e.CwTriangle == null || e.CcwTriangle == null)
                        newFrontEdges.Insert(e);

            foreach (var e in newFrontEdges)
                AddEdgeToFront(e);
        }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:10,代码来源:EdgeInserter.cs

示例2: SetOfActiveNodesIsLargerThanThreshold

 private static bool SetOfActiveNodesIsLargerThanThreshold(Cluster ancestor, Node node, Set<Node> usedNodeSet, int threshold) {
     Cluster parent = Parent(node);
     do {
         foreach (var n in Children(parent)) {
             usedNodeSet.Insert(n);
             if (usedNodeSet.Count > threshold)
                 return true;
         }
         if (parent == ancestor)
             break;
         parent = Parent(parent);
     } while (true);
     
     usedNodeSet.Insert(parent);
     return usedNodeSet.Count > threshold;
 }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:16,代码来源:ShapeCreatorForRoutingToParents.cs

示例3: GetVisibleTilesSet

        Set<Tuple<int, int, int>> GetVisibleTilesSet() {
            int iLevel = GetBackgroundTileLevel();
            GridTraversal grid = new GridTraversal(GeomGraph.BoundingBox, iLevel);
            var tiles = new Set<Triple>();
            var visibleRectangle = GetVisibleRectangleInGraph();

            var t1 = grid.PointToTuple(visibleRectangle.LeftBottom);
            var t2 = grid.PointToTuple(visibleRectangle.RightTop);

            for (int ix = t1.Item1; ix <= t2.Item1; ix++)
                for (int iy = t1.Item2; iy <= t2.Item2; iy++) {
                    var t = new Triple(iLevel, ix, iy);

                    TileType tileType;
                    if (!_tileDictionary.TryGetValue(t, out tileType)) continue;
                    if (tileType == TileType.Image) tiles.Insert(t);
                }

            return tiles;
        }
开发者ID:matthagenbuch,项目名称:automatic-graph-layout,代码行数:20,代码来源:GraphmapsViewer.cs

示例4: FillExistingNodesEdges

        void FillExistingNodesEdges(Set<Node> existindNodes, Set<DrawingEdge> existingEdges) {
            foreach (var dro in _drawingObjectsToIViewerObjects.Keys) {
                var n = dro as Node;

                if (n != null && dro.IsVisible) //added: visibility
                    existindNodes.Insert(n);
                else {
                    var edge = dro as DrawingEdge;
                    if (edge != null && dro.IsVisible)
                        existingEdges.Insert((DrawingEdge) dro);
                }
            }
        }
开发者ID:matthagenbuch,项目名称:automatic-graph-layout,代码行数:13,代码来源:GraphmapsViewer.cs

示例5: GetIntersectingVisibleRectangle

 private Set<Node> GetIntersectingVisibleRectangle(Set<Node> fakeTileNodes)
 {
     var rect = GetVisibleRectangleInGraph();
     var nodes = new Set<Node>();
     foreach (var node in fakeTileNodes)
     {
         IViewerObject o;
         if (!_drawingObjectsToIViewerObjects.TryGetValue(node, out o)) continue;
         var vnode = ((GraphmapsNode)o);
         if (NodeDotRect(vnode.LgNodeInfo).Intersects(rect))
         {
             nodes.Insert(node);
         }
     }
     return nodes;
 }
开发者ID:matthagenbuch,项目名称:automatic-graph-layout,代码行数:16,代码来源:GraphmapsViewer.cs

示例6: treeDataGridView_PreviewKeyDown

        void treeDataGridView_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
                treeDataGridView.ClearSelection();

            if (e.KeyCode != Keys.Enter)
                return;

            var newDataFilter = new DataFilter { FilterSource = this, Analysis = new List<Analysis>() };

            if (treeDataGridView.SelectedCells.Count == 0)
                return;

            var processedRows = new Set<int>();

            foreach (DataGridViewCell cell in treeDataGridView.SelectedCells)
            {
                if (!processedRows.Insert(cell.RowIndex).WasInserted)
                    continue;

                var rowIndexHierarchy = treeDataGridView.GetRowHierarchyForRowIndex(cell.RowIndex);
                var row = GetRowFromRowHierarchy(rowIndexHierarchy) as AnalysisRow;
                if (row != null) newDataFilter.Analysis.Add(row.Analysis);
            }

            if (AnalysisViewFilter != null)
                AnalysisViewFilter(this, new ViewFilterEventArgs(newDataFilter));
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:28,代码来源:AnalysisTableForm.cs

示例7: applyAssemblyText

        private List<SpectrumSourceGroup> applyAssemblyText(ISession session, string filepath)
        {
            var spectrumSources = session.Query<SpectrumSource>().ToList();
            var sourcesByGroup = new Map<string, List<SpectrumSource>>();
            var alreadyGroupedSources = new Set<string>();
            var sourceGroups = new List<SpectrumSourceGroup>();

            // open the assembly.txt file
            using (var assembleTxtFile = File.OpenText(filepath))
            {
                string line;
                while ((line = assembleTxtFile.ReadLine()) != null)
                {
                    if (line.Length == 0)
                        continue;

                    try
                    {
                        Regex groupFilemaskPair = new Regex("((\"(.+)\")|(\\S+))\\s+((\"(.+)\")|(\\S+))");
                        Match lineMatch = groupFilemaskPair.Match(line);
                        string group = lineMatch.Groups[3].ToString() + lineMatch.Groups[4].ToString();
                        string filemask = lineMatch.Groups[7].ToString() + lineMatch.Groups[8].ToString();

                        // for wildcards, use old style behavior
                        if (filemask.IndexOfAny("*?".ToCharArray()) > -1)
                        {
                            if (!Path.IsPathRooted(filemask))
                                filemask = Path.Combine(Path.GetDirectoryName(filepath), filemask);

                            if (!sourcesByGroup.Contains(group))
                                sourcesByGroup[group] = new List<SpectrumSource>();

                            if (!Directory.Exists(Path.GetDirectoryName(filemask)))
                                continue;

                            var files = Directory.GetFiles(Path.GetDirectoryName(filemask), Path.GetFileName(filemask));
                            var sourceNames = files.Select(o => Path.GetFileNameWithoutExtension(o));
                            foreach (string sourceName in sourceNames)
                            {
                                var spectrumSource = spectrumSources.SingleOrDefault(o => o.Name == sourceName);
                                if (spectrumSource == null)
                                    continue;

                                var insertResult = alreadyGroupedSources.Insert(sourceName);
                                if (insertResult.WasInserted)
                                    sourcesByGroup[group].Add(spectrumSource);
                            }
                        }
                        else
                        {
                            // otherwise, match directly to source names
                            string sourceName = Path.GetFileNameWithoutExtension(filemask);
                            var spectrumSource = spectrumSources.SingleOrDefault(o => o.Name == sourceName);
                            if (spectrumSource == null)
                                continue;

                            var insertResult = alreadyGroupedSources.Insert(sourceName);
                            if (insertResult.WasInserted)
                                sourcesByGroup[group].Add(spectrumSource);
                        }
                    }
                    catch (Exception ex)
                    {
                        Program.HandleException(new Exception("Error reading assembly text from \"" + filepath + "\": " + ex.Message, ex));
                    }
                }
            }

            // remove existing groups
            RemoveGroupNode(_rootNode, false);

            sourceGroups.Add(new SpectrumSourceGroup { Name = "/" });

            // build new group hierarchy
            foreach (var itr in sourcesByGroup)
            {
                if (itr.Value.IsNullOrEmpty())
                    continue;

                var ssg = new SpectrumSourceGroup { Name = itr.Key };
                if (!alreadyGroupedSources.Contains(ssg.Name))
                    sourceGroups.Add(ssg);

                // decompose group path into segments, e.g. /foo/bar/ -> {foo, bar}
                IEnumerable<string> segments = ssg.Name.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                segments = segments.Take(segments.Count() - 1); // ignore the last segment

                var parentNode = _rootNode;
                foreach(string segment in segments)
                {
                    var segmentNode = parentNode.Children.FirstOrDefault(o => o.Text == segment);
                    if (segmentNode == null)
                    {
                        var segmentGroup = new SpectrumSourceGroup { Name = (parentNode.Text + "/").Replace("//", "/") + segment };
                        if (!alreadyGroupedSources.Contains(segmentGroup.Name))
                            sourceGroups.Add(segmentGroup);

                        segmentNode = new tlvBranch
                        {
                            Text = segment,
//.........这里部分代码省略.........
开发者ID:lgatto,项目名称:proteowizard,代码行数:101,代码来源:GroupingControlForm.cs

示例8: treeDataGridView_PreviewKeyDown

        void treeDataGridView_PreviewKeyDown (object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
                treeDataGridView.ClearSelection();

            if (e.KeyCode != Keys.Enter)
                return;

            var newDataFilter = new DataFilter { FilterSource = this };

            if (treeDataGridView.SelectedCells.Count == 0)
                return;

            var processedRows = new Set<int>();
            var selectedSourceGroups = new List<SpectrumSourceGroup>();
            var selectedSources = new List<SpectrumSource>();
            var selectedSpectra = new List<Spectrum>();
            var selectedAnalyses = new List<Analysis>();
            var selectedPeptides = new List<Peptide>();
            var selectedCharges = new List<int>();
            var selectedMatches = new List<PeptideSpectrumMatchRow>();

            foreach (DataGridViewCell cell in treeDataGridView.SelectedCells)
            {
                if (!processedRows.Insert(cell.RowIndex).WasInserted)
                    continue;

                var rowIndexHierarchy = treeDataGridView.GetRowHierarchyForRowIndex(cell.RowIndex);
                Row row = GetRowFromRowHierarchy(rowIndexHierarchy);

                if (row is SpectrumSourceGroupRow)
                    selectedSourceGroups.Add((row as SpectrumSourceGroupRow).SpectrumSourceGroup);
                else if (row is SpectrumSourceRow)
                    selectedSources.Add((row as SpectrumSourceRow).SpectrumSource);
                else if (row is SpectrumRow)
                    selectedSpectra.Add((row as SpectrumRow).Spectrum);
                else if (row is AnalysisRow)
                    selectedAnalyses.Add((row as AnalysisRow).Analysis);
                else if (row is PeptideRow)
                    selectedPeptides.Add((row as PeptideRow).Peptide);
                else if (row is ChargeRow)
                    selectedCharges.Add((row as ChargeRow).Charge);
                else if (row is PeptideSpectrumMatchRow)
                    selectedMatches.Add(row as PeptideSpectrumMatchRow);
            }

            if (selectedSourceGroups.Count > 0) newDataFilter.SpectrumSourceGroup = selectedSourceGroups;
            if (selectedSources.Count > 0) newDataFilter.SpectrumSource = selectedSources;
            if (selectedSpectra.Count > 0) newDataFilter.Spectrum = selectedSpectra;
            if (selectedAnalyses.Count > 0) newDataFilter.Analysis = selectedAnalyses;
            if (selectedPeptides.Count > 0) newDataFilter.Peptide = selectedPeptides;
            if (selectedCharges.Count > 0) newDataFilter.Charge = selectedCharges;

            // TODO: visualize multiple PSMs?
            //if (selectedMatches.Count > 0)

            if (SpectrumViewFilter != null)
                SpectrumViewFilter(this, new ViewFilterEventArgs(newDataFilter));
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:59,代码来源:SpectrumTableForm.cs


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