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


C# Set.Contains方法代码示例

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


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

示例1: IsSimple

 /// <summary>
 /// A MultiPoint is simple if it has no repeated points.
 /// </summary>
 public bool IsSimple(IMultiPoint mp)
 {
     if (mp.IsEmpty) 
         return true;
     Set<ICoordinate> points = new Set<ICoordinate>();
     for (int i = 0; i < mp.NumGeometries; i++)
     {
         IPoint pt = (IPoint) mp.GetGeometryN(i);
         ICoordinate p = pt.Coordinate;
         if (points.Contains(p))
             return false;
         points.Add(p);
     }
     return true;
 }   
开发者ID:lishxi,项目名称:_SharpMap,代码行数:18,代码来源:IsSimpleOp.cs

示例2: Init

		public void Init(FdoCache cache, bool enableCancel)
		{
			CheckDisposed();

			m_cache = cache;
			m_btnCancel.Visible = enableCancel;
			Set<int> revIdxWs = new Set<int>(4);
			foreach (IReversalIndex ri in cache.LangProject.LexDbOA.ReversalIndexesOC)
				revIdxWs.Add(ri.WritingSystemRAHvo);
			// Include only the analysis writing systems chosen by the user.  See LT-7514 and LT-7239.
			Set<int> activeWs = new Set<int>(8);
			foreach (int ws in cache.LangProject.AnalysisWssRC.HvoArray)
				activeWs.Add(ws);
			m_cbWritingSystems.Sorted = true;
			m_cbWritingSystems.DisplayMember = "Name";
			NamedWritingSystem nwsSelected = null;
			foreach (NamedWritingSystem nws in cache.LangProject.GetDbNamedWritingSystems())
			{
				if (revIdxWs.Contains(nws.Hvo))
				{
					AddLanguageForExistingRevIdx(nws.IcuLocale);
					continue;
				}
				if (!activeWs.Contains(nws.Hvo))
					continue;
				m_cbWritingSystems.Items.Add(nws);
				if (nwsSelected == null && !LanguageMatchesExistingRevIdx(nws.IcuLocale))
					nwsSelected = nws;
			}
			if (nwsSelected != null)
				m_cbWritingSystems.SelectedItem = nwsSelected;
			if (m_cbWritingSystems.Items.Count > 0 && m_cbWritingSystems.SelectedIndex < 0)
				m_cbWritingSystems.SelectedIndex = 0;
			if (!enableCancel && m_cbWritingSystems.Items.Count == 0)
				throw new ApplicationException("Cancel is disabled, but there are none to choose, so the user has no way to get out of this dialog.");
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:36,代码来源:CreateReversalIndexDlg.cs

示例3: FunctionImportStructuralTypeMappingKB

        internal FunctionImportStructuralTypeMappingKB(
            IEnumerable<FunctionImportStructuralTypeMapping> structuralTypeMappings,
            ItemCollection itemCollection)
        {
            DebugCheck.NotNull(structuralTypeMappings);
            DebugCheck.NotNull(itemCollection);

            m_itemCollection = itemCollection;

            // If no specific type mapping.
            if (structuralTypeMappings.Count() == 0)
            {
                // Initialize with defaults.
                ReturnTypeColumnsRenameMapping = new Dictionary<string, FunctionImportReturnTypeStructuralTypeColumnRenameMapping>();
                NormalizedEntityTypeMappings =
                    new ReadOnlyCollection<FunctionImportNormalizedEntityTypeMapping>(
                        new List<FunctionImportNormalizedEntityTypeMapping>());
                DiscriminatorColumns = new ReadOnlyCollection<string>(new List<string>());
                MappedEntityTypes = new ReadOnlyCollection<EntityType>(new List<EntityType>());
                return;
            }

            var entityTypeMappings = structuralTypeMappings.OfType<FunctionImportEntityTypeMapping>();

            // FunctionImportEntityTypeMapping
            if (null != entityTypeMappings
                && null != entityTypeMappings.FirstOrDefault())
            {
                var isOfTypeEntityTypeColumnsRenameMapping =
                    new Dictionary<EntityType, Collection<FunctionImportReturnTypePropertyMapping>>();
                var entityTypeColumnsRenameMapping = new Dictionary<EntityType, Collection<FunctionImportReturnTypePropertyMapping>>();
                var normalizedEntityTypeMappings = new List<FunctionImportNormalizedEntityTypeMapping>();

                // Collect all mapped entity types.
                MappedEntityTypes = entityTypeMappings
                    .SelectMany(mapping => mapping.GetMappedEntityTypes(m_itemCollection))
                    .Distinct()
                    .ToList()
                    .AsReadOnly();

                // Collect all discriminator columns.
                DiscriminatorColumns = entityTypeMappings
                    .SelectMany(mapping => mapping.GetDiscriminatorColumns())
                    .Distinct()
                    .ToList()
                    .AsReadOnly();

                m_entityTypeLineInfos = new KeyToListMap<EntityType, LineInfo>(EqualityComparer<EntityType>.Default);
                m_isTypeOfLineInfos = new KeyToListMap<EntityType, LineInfo>(EqualityComparer<EntityType>.Default);

                foreach (var entityTypeMapping in entityTypeMappings)
                {
                    // Remember LineInfos for error reporting.
                    foreach (var entityType in entityTypeMapping.EntityTypes)
                    {
                        m_entityTypeLineInfos.Add(entityType, entityTypeMapping.LineInfo);
                    }
                    foreach (var isTypeOf in entityTypeMapping.IsOfTypeEntityTypes)
                    {
                        m_isTypeOfLineInfos.Add(isTypeOf, entityTypeMapping.LineInfo);
                    }

                    // Create map from column name to condition.
                    var columnMap = entityTypeMapping.Conditions.ToDictionary(
                        condition => condition.ColumnName,
                        condition => condition);

                    // Align conditions with discriminator columns.
                    var columnMappings = new List<FunctionImportEntityTypeMappingCondition>(DiscriminatorColumns.Count);
                    for (var i = 0; i < DiscriminatorColumns.Count; i++)
                    {
                        var discriminatorColumn = DiscriminatorColumns[i];
                        FunctionImportEntityTypeMappingCondition mappingCondition;
                        if (columnMap.TryGetValue(discriminatorColumn, out mappingCondition))
                        {
                            columnMappings.Add(mappingCondition);
                        }
                        else
                        {
                            // Null indicates the value for this discriminator doesn't matter.
                            columnMappings.Add(null);
                        }
                    }

                    // Create bit map for implied entity types.
                    var impliedEntityTypesBitMap = new bool[MappedEntityTypes.Count];
                    var impliedEntityTypesSet = new Set<EntityType>(entityTypeMapping.GetMappedEntityTypes(m_itemCollection));
                    for (var i = 0; i < MappedEntityTypes.Count; i++)
                    {
                        impliedEntityTypesBitMap[i] = impliedEntityTypesSet.Contains(MappedEntityTypes[i]);
                    }

                    // Construct normalized mapping.
                    normalizedEntityTypeMappings.Add(
                        new FunctionImportNormalizedEntityTypeMapping(this, columnMappings, new BitArray(impliedEntityTypesBitMap)));

                    // Construct the rename mappings by adding isTypeOf types and specific entity types to the corresponding lists.
                    foreach (var isOfType in entityTypeMapping.IsOfTypeEntityTypes)
                    {
                        if (!isOfTypeEntityTypeColumnsRenameMapping.Keys.Contains(isOfType))
//.........这里部分代码省略.........
开发者ID:christiandpena,项目名称:entityframework,代码行数:101,代码来源:FunctionImportStructuralTypeMappingKB.cs

示例4: CalculateSubDirOrder

		// utility function for finding the correct order to process directories
		List<SolutionFolderItem> CalculateSubDirOrder (AutotoolsContext ctx, SolutionFolder folder, SolutionConfiguration config)
		{
			List<SolutionFolderItem> resultOrder = new List<SolutionFolderItem>();
			Set<SolutionFolderItem> dependenciesMet = new Set<SolutionFolderItem>();
			Set<SolutionFolderItem> inResult = new Set<SolutionFolderItem>();
			
			// We don't have to worry about projects built in parent combines
			dependenciesMet.Union (ctx.GetBuiltProjects ());

			bool added;
			string notMet;
			do 
			{
				added = false;
				notMet = null;
				
				List<SolutionFolderItem> items = new List<SolutionFolderItem> ();
				GetSubItems (items, folder);

				foreach (SolutionFolderItem item in items) 
				{
					Set<SolutionFolderItem> references, provides;
					
					if (inResult.Contains (item))
						continue;
					
					if (item is SolutionItem)
					{
						SolutionItem entry = (SolutionItem) item;
						if (!config.BuildEnabledForItem (entry))
							continue;
						
						references = new Set<SolutionFolderItem> ();
						provides = new Set<SolutionFolderItem>();
						references.Union (entry.GetReferencedItems (config.Selector));
						provides.Add (entry);
					}
					else if (item is SolutionFolder) {
						GetAllProjects ((SolutionFolder) item, config, out provides, out references);
					}
					else
						continue;
	
					if (dependenciesMet.ContainsSet (references) ) 
					{
						resultOrder.Add (item);
						dependenciesMet.Union(provides);
						inResult.Add(item);
						added = true;
					} 
					else notMet = item.Name;
				}
			} while (added);

			if (notMet != null) 
				throw new Exception("Impossible to find a solution order that satisfies project references for '" + notMet + "'");

			return resultOrder;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:60,代码来源:SolutionMakefileHandler.cs

示例5: PublishDir

		void PublishDir (Set<FilePath> dirs, FilePath dir, bool rec, IProgressMonitor monitor)
		{
			string ndir = (string) dir;
			while (ndir[ndir.Length - 1] == Path.DirectorySeparatorChar)
				ndir = ndir.Substring (0, ndir.Length - 1);

			dir = ndir;
			if (dirs.Contains (dir))
				return;

			dirs.Add (dir);
			if (rec) {
				PublishDir (dirs, dir.ParentDirectory, true, monitor);
				Add (dir, false, monitor);
			}
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:16,代码来源:SubversionRepository.cs

示例6: TryFirstWsInList

		static internal bool TryFirstWsInList(SIL.FieldWorks.Common.COMInterfaces.ISilDataAccess sda, int hvo, int flid,
			int[] wssToTry, ref Set<int> wssTried, out int retWs, out ITsString retTss)
		{
			retTss = null;
			retWs = 0;
			foreach (int wsLoop in wssToTry)
			{
				if (wssTried.Contains(wsLoop))
					continue;
				wssTried.Add(wsLoop);
				retTss = sda.get_MultiStringAlt(hvo, flid, wsLoop);
				if (retTss.Length > 0)
				{
					retWs = wsLoop;
					return true;
				}
			}
			return false;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:19,代码来源:LangProject.cs

示例7: FindBestLexEntryAmongstHomographs

		/// <summary>
		/// find the best existing LexEntry option matching 'homographform' (and possibly 'sDefnTarget')
		/// in order to determine if we should merge leTarget into that entry.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="homographForm"></param>
		/// <param name="sDefnTarget"></param>
		/// <param name="leTarget">a LexEntry that you want to consider merging into a more appropriate LexEntry,
		/// if null, we ignore 'newHvos' and 'hvoDomain'</param>
		/// <param name="newHvos"></param>
		/// <param name="hvoDomain"></param>
		/// <param name="fGotExactMatch"></param>
		/// <returns></returns>
		private static ILexEntry FindBestLexEntryAmongstHomographs(FdoCache cache,
			string homographForm, string sDefnTarget, ILexEntry leTarget, Set<int> newHvos,
			int hvoDomain, out bool fGotExactMatch)
		{
			ILexEntry leSaved = null;
			List<ILexEntry> rgEntries = LexEntry.CollectHomographs(homographForm, 0,
				LexEntry.GetHomographList(cache, homographForm),
				MoMorphType.kmtStem, true);
			leSaved = null; // saved entry to merge into (from previous iteration)
			bool fSavedIsOld = false; // true if leSaved is old (and non-null).
			fGotExactMatch = false; // true if we find a match for cf AND defn.
			bool fCurrentIsNew = false;
			foreach (ILexEntry leCurrent in rgEntries)
			{
				if (leTarget != null)
				{
					if (leCurrent.Hvo == leTarget.Hvo)
						continue; // not interested in merging with ourself.
					// See if this is one of the newly added entries. If it is, it has exactly one sense,
					// and that sense is in our list.
					fCurrentIsNew = leCurrent.SensesOS.Count == 1 && newHvos.Contains(leCurrent.SensesOS.HvoArray[0]);
					if (fCurrentIsNew && leCurrent.Hvo > leTarget.Hvo)
						continue;  // won't consider ANY kind of merge with a new object of greater HVO.
				}
				// Decide whether lexE should be noted as the entry that we will merge with if
				// we don't find an exact match.
				if (!fGotExactMatch) // leMerge is irrelevant if we already got an exact match.
				{
					if (leSaved == null)
					{
						leSaved = leCurrent;
						fSavedIsOld = !fCurrentIsNew;
					}
					else // we have already found a candidate
					{
						if (fSavedIsOld)
						{
							// We will only consider the new one if it is also old, and
							// (rather arbitrarily) if it has a smaller HVO
							if ((!fCurrentIsNew) && leCurrent.Hvo < leSaved.Hvo)
							{
								leSaved = leCurrent; // fSavedIsOld stays true.
							}
						}
						else // we already have a candidate, but it is another of the new entries
						{
							// if current is old, we'll use it for sure
							if (!fCurrentIsNew)
							{
								leSaved = leCurrent;
								fSavedIsOld = false; // since fCurrentIsNew is false.
							}
							else
							{
								// we already have a new candidate (which must have a smaller hvo than target)
								// and now we have another new entry which matches!
								// We'll prefer it only if its hvo is smaller still.
								if (leCurrent.Hvo < leSaved.Hvo)
								{
									leSaved = leCurrent; // fSavedIsOld stays false.
								}
							}
						}
					}
				}

				// see if we want to try to find a matching existing sense.
				if (sDefnTarget == null)
					continue;
				// This deals with all senses in the entry,
				// whether owned directly by the entry or by its senses
				// at whatever level.
				// If the new definition matches an existing defintion (or if both
				// are missing) add the current domain to the existing sense.
				// Note: if more than one sense has the same definition (maybe missing) we should
				// add the domain to all senses--not just the first one encountered.
				foreach (ILexSense lexS in leCurrent.AllSenses)
				{
					if (lexS.Definition != null
						&& lexS.Definition.AnalysisDefaultWritingSystem != null)
					{
						string sDefnCurrent = lexS.Definition.AnalysisDefaultWritingSystem.UnderlyingTsString.Text;
						if ((sDefnCurrent == null && sDefnTarget == null) ||
							(sDefnCurrent != null && sDefnTarget != null && sDefnCurrent.Trim() == sDefnTarget.Trim()))
						{
							// We found a sense that has the same citation form and definition as the one
							// we're trying to merge.
//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:WorldPad,代码行数:101,代码来源:LingOverrides.cs

示例8: DeleteUnusedMSAs

		/// <summary>
		/// Delete any MSAs that are no longer referenced by a sense (or subsense).
		/// </summary>
		private void DeleteUnusedMSAs()
		{
			Set<int> msasUsed = new Set<int>();
			foreach (int hvo in this.AllSenseHvos)
			{
				int hvoMsa = m_cache.GetObjProperty(hvo, (int)LexSense.LexSenseTags.kflidMorphoSyntaxAnalysis);
				if (hvoMsa != 0)
					msasUsed.Add(hvoMsa);
			}
			Set<int> hvosObsolete = new Set<int>();
			foreach (int hvo in this.MorphoSyntaxAnalysesOC.HvoArray)
			{
				if (!msasUsed.Contains(hvo))
					hvosObsolete.Add(hvo);
			}
			if (hvosObsolete.Count > 0)
				CmObject.DeleteObjects(hvosObsolete, m_cache);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:21,代码来源:LingOverrides.cs

示例9: InsertObject


//.........这里部分代码省略.........
							if (hvoTarget == sda.get_VecItem(hvoOwner, flid, i))
							{
								insertionPosition = i + 1; // insert after current object.
								fGotIt = true; // break outer loop
								break;
							}
						}
					}
				}
			}
			var slices = new Set<Slice>(ContainingDataTree.Slices);

			// Save DataTree for the finally block.  Note premature return below due to IsDisposed.  See LT-9005.
			DataTree dtContainer = ContainingDataTree;
			try
			{
				dtContainer.SetCurrentObjectFlids(hvoOwner, flid);
				var fieldType = (CellarPropertyType) m_cache.MetaDataCacheAccessor.GetFieldType(flid);
				switch (fieldType)
				{
					case CellarPropertyType.OwningCollection:
						insertionPosition = -1;
						break;

					case CellarPropertyType.OwningAtomic:
						insertionPosition = -2;
						break;
				}
				using (CmObjectUi uiObj = CmObjectUi.CreateNewUiObject(m_mediator, newObjectClassId, hvoOwner, flid, insertionPosition))
				{
					// If uiObj is null, typically CreateNewUiObject displayed a dialog and the user cancelled.
					// We return -1 to make the caller give up trying to insert, so we don't get another dialog if
					// there is another slice that could insert this kind of object.
					// If 'this' isDisposed, typically the inserted object occupies a place in the record list for
					// this view, and inserting an object caused the list to be refreshed and all slices for this
					// record to be disposed. In that case, we won't be able to find a child of this to activate,
					// so we'll just settle for having created the object.
					// Enhance JohnT: possibly we could load information from the slice into local variables before
					// calling CreateNewUiObject so that we could do a better job of picking the slice to focus
					// after an insert which disposes 'this'. Or perhaps we could improve the refresh list process
					// so that it more successfully restores the current item without disposing of all the slices.
					if (IsDisposed)
						return -1;
					if (uiObj == null)
						return -2; // Nothing created.

					switch (fieldType)
					{
						case CellarPropertyType.OwningCollection:
							// order is not fully predicatable, figure where it DID show up.
							insertionPosition = m_cache.DomainDataByFlid.GetObjIndex(hvoOwner, flid, uiObj.Object.Hvo);
							break;

						case CellarPropertyType.OwningAtomic:
							insertionPosition = 0;
							break;
					}

					//			if (ihvoPosition == ClassAndPropInfo.kposNotSet && cpi.fieldType == DataTree.kcptOwningSequence)
					//			{
					//				// insert at end of sequence.
					//				ihvoPosition = cache.DomainDataByFlid.get_VecSize(hvoOwner, (int)cpi.flid);
					//			} // otherwise we already worked out the position or it doesn't matter
					//			// Note: ihvoPosition ignored if sequence(?) or atomic.
					//			int hvoNew = cache.CreateObject((int)(cpi.signatureClsid), hvoOwner, (int)(cpi.flid), ihvoPosition);
					//			cache.DomainDataByFlid.PropChanged(null, (int)PropChangeType.kpctNotifyAll, hvoOwner, (int)(cpi.flid), ihvoPosition, 1, 0);
					if (hvoOwner == Object.Hvo && Expansion == DataTree.TreeItemState.ktisCollapsed)
					{
						// We added something to the object of the current slice...almost certainly it
						// will be something that will display under this node...if it is still collapsed,
						// expand it to show the thing inserted.
						TreeNode.ToggleExpansion(IndexInContainer);
					}
					Slice child = ExpandSubItem(uiObj.Object.Hvo);
					if (child != null)
						child.FocusSliceOrChild();
					else
					{
						// If possible, jump to the newly inserted sub item.
						if (m_mediator.BroadcastMessageUntilHandled("JumpToRecord", uiObj.Object.Hvo))
							return insertionPosition;
						// If we haven't found a slice...common now, because there's rarely a need to expand anything...
						// and some slice was added, focus it.
						foreach (Slice slice in Parent.Controls)
						{
							if (!slices.Contains(slice))
							{
								slice.FocusSliceOrChild();
								break;
							}
						}
					}
				}
			}
			finally
			{
				dtContainer.ClearCurrentObjectFlids();
			}
			return insertionPosition;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:Slice.cs

示例10: CheckNoSelfIntersectingRing

 /// <summary>
 /// Check that a ring does not self-intersect, except at its endpoints.
 /// Algorithm is to count the number of times each node along edge occurs.
 /// If any occur more than once, that must be a self-intersection.
 /// </summary>
 private void CheckNoSelfIntersectingRing(EdgeIntersectionList eiList)
 {
     Set<Coordinate> nodeSet = new Set<Coordinate>();    
     bool isFirst = true;
     foreach(EdgeIntersection ei in eiList)
     {                
         if (isFirst)
         {
             isFirst = false;
             continue;
         }
         if (nodeSet.Contains(ei.Coordinate))
         {
             validErr = new TopologyValidationError(TopologyValidationErrors.RingSelfIntersection, ei.Coordinate);
             return;
         }
         else nodeSet.Add(ei.Coordinate);
     }
 }
开发者ID:dathayer23,项目名称:NetTopologySuite,代码行数:24,代码来源:IsValidOp.cs

示例11: assembleMinimumCoveringSet

        public void assembleMinimumCoveringSet(ClusterInfo c)
        {
            if (c.proteinGroups.Count == 1) // degenerate case
            {
                foreach (ProteinGroupInfo proGroup in c.proteinGroups)
                    proGroup.uniquePeptideCount = int.MaxValue; // value is n/a
                return;
            }

            /*Set<ResultInfo> clusterResults = new Set<ResultInfo>( c.results );
            ProteinGroupList clusterGroups = new ProteinGroupList();
            foreach( ProteinGroupInfo proGroup in c.proteinGroups )
                clusterGroups.Add( proGroup );
            //Console.WriteLine(); 
            while( clusterResults.Count > 0 )
            {
                List<ProteinGroupInfo> minRemainingResults = new List<ProteinGroupInfo>();
                int minRemainingResultCount = clusterResults.Count;
                //int n = 0;
                //Console.WriteLine( "groups: " + clusterGroups.Count + "; results: " + clusterResults.Count );
                foreach( ProteinGroupInfo proGroup in clusterGroups )
                {
                    //Console.Write( n++ + " of " + clusterGroups.Count + "\r" );
                    int count = clusterResults.Count;
                    foreach( ResultInfo r in proGroup.results )
                        if( clusterResults.Contains( r ) )
                            --count;
                    if( count <= minRemainingResultCount )
                    {
                        if( count < minRemainingResultCount )
                            minRemainingResults.Clear();
                        minRemainingResults.Add( proGroup );
                    }
                }

                ProteinGroupInfo mostGreedyGroup = minRemainingResults[0];
                minRemainingResults.Clear();
                int oldCount = clusterResults.Count;
                clusterResults.Subtract( mostGreedyGroup.results );
                if( clusterResults.Count >= oldCount )
                {
                    Console.Error.WriteLine( "Something has gone terribly wrong!" );
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
                }

                mostGreedyGroup.minSet = true;
                clusterGroups.Remove( mostGreedyGroup );
            }*/

            // Get the results in the cluster
            Set<ResultInfo> clusterResults = new Set<ResultInfo>(c.results);
            // Get the protein groups in the cluster
            ProteinGroupList clusterGroups = new ProteinGroupList();
            foreach (ProteinGroupInfo proGroup in c.proteinGroups)
                clusterGroups.Add(proGroup);
            //Console.WriteLine(); 
            // while there are results in the cluster
            while (clusterResults.Count > 0)
            {
                // Maps the number of results to a protein group
                Map<int, List<ProteinGroupInfo>> remainingResults = new Map<int, List<ProteinGroupInfo>>();
                //int n = 0;
                //Console.WriteLine( "groups: " + clusterGroups.Count + "; results: " + clusterResults.Count );
                // Iterate through protein groups
                foreach (ProteinGroupInfo proGroup in clusterGroups)
                {
                    //Console.Write( n++ + " of " + clusterGroups.Count + "\n" );
                    // Get the number of results in the cluster
                    int count = clusterResults.Count;
                    // Iterate over the cluster results and see how 
                    // many cluster group results can be explained
                    // by that protein group
                    foreach (ResultInfo r in proGroup.results)
                    {
                        if (clusterResults.Contains(r))
                            --count;
                    }
                    // Map the number of remaining results to that
                    // protein group
                    remainingResults[count].Add(proGroup);
                }

                // Take the first protein group that can explain the most results
                ProteinGroupInfo mostGreedyGroup = remainingResults.Values[0][0];
                // Subtract its results from the cluster results
                mostGreedyGroup.uniquePeptideCount = clusterResults.Count - remainingResults.Keys[0];
                clusterResults.Subtract(mostGreedyGroup.results);
                // Remove the most greedy group from the cluster groups
                clusterGroups.Remove(mostGreedyGroup);
            }
        }
开发者ID:hap-adong,项目名称:IDPicker,代码行数:91,代码来源:Program.cs

示例12: GetDigraphs

		/// <summary>
		/// Get the set of significant digraphs (multigraphs) for the writing system.  At the
		/// moment, these are derived from ICU sorting rules associated with the writing system.
		/// </summary>
		private Set<string> GetDigraphs(string sWs, out Dictionary<string, string> mapChars)
		{
			Set<string> digraphs = null;
			if (m_mapWsDigraphs.TryGetValue(sWs, out digraphs))
			{
				mapChars = m_mapWsMapChars[sWs];
				return digraphs;
			}
			digraphs = new Set<string>();
			mapChars = new Dictionary<string, string>();
			int ws = m_cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr(sWs);
			IWritingSystem wsX = null;
			ICollation coll = null;
			string sIcuRules = null;
			if (ws > 0)
			{
				wsX = m_cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(ws);
				if (wsX.CollationCount > 0)
				{
					coll = wsX.get_Collation(0);
					sIcuRules = coll.IcuRules;
					if (String.IsNullOrEmpty(sIcuRules))
					{
						// The ICU rules may not be loaded for built-in languages, but are
						// still helpful for our purposes here.
						string sIcuOrig = sIcuRules;
						coll.LoadIcuRules(sWs);
						sIcuRules = coll.IcuRules;
						coll.IcuRules = sIcuOrig;	// but we don't want to actually change anything!
					}
				}
			}
			if (!String.IsNullOrEmpty(sIcuRules) && sIcuRules.Contains("&"))
			{
				string[] rgsRules = sIcuRules.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
				for (int i = 0; i < rgsRules.Length; ++i)
				{
					string sRule = rgsRules[i];
					// This is a valid rule that specifies that the digraph aa should be ignored
					// [last tertiary ignorable] = \u02bc = aa
					// but the code here will ignore this. YAGNI the chances of a user specifying a digraph
					// as ignorable may never happen.
					if (sRule.Contains("["))
						sRule = sRule.Substring(0, sRule.IndexOf("["));
					if (String.IsNullOrEmpty(sRule.Trim()))
						continue;
					sRule = sRule.Replace("<<<", "=");
					sRule = sRule.Replace("<<", "=");
					if (sRule.Contains("<"))
					{
						// "&N<ng<<<Ng<ny<<<Ny" => "&N<ng=Ng<ny=Ny"
						// "&N<ñ<<<Ñ" => "&N<ñ=Ñ"
						// There are other issues we are not handling proplerly such as the next line
						// &N<\u006e\u0067
						string[] rgsPieces = sRule.Split(new char[] { '<', '=' }, StringSplitOptions.RemoveEmptyEntries);
						for (int j = 0; j < rgsPieces.Length; ++j)
						{
							string sGraph = rgsPieces[j];
							sGraph = sGraph.Trim();
							if (String.IsNullOrEmpty(sGraph))
								continue;
							sGraph = Icu.Normalize(sGraph, Icu.UNormalizationMode.UNORM_NFD);
							if (sGraph.Length > 1)
							{
								sGraph = Icu.ToLower(sGraph, sWs);
								if (!digraphs.Contains(sGraph))
									digraphs.Add(sGraph);
							}
						}
					}
					else if (sRule.Contains("="))
					{
						// "&ae<<æ<<<Æ" => "&ae=æ=Æ"
						string[] rgsPieces = sRule.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
						string sGraphPrimary = rgsPieces[0].Trim();
						Debug.Assert(!String.IsNullOrEmpty(sGraphPrimary));
						sGraphPrimary = Icu.ToLower(sGraphPrimary, sWs);
						for (int j = 1; j < rgsPieces.Length; ++j)
						{
							string sGraph = rgsPieces[j];
							sGraph = sGraph.Trim();
							if (String.IsNullOrEmpty(sGraph))
								continue;
							sGraph = Icu.Normalize(sGraph, Icu.UNormalizationMode.UNORM_NFD);
							sGraph = Icu.ToLower(sGraph, sWs);
							if (sGraph != sGraphPrimary)
							{
								if (!mapChars.ContainsKey(sGraph))
									mapChars.Add(sGraph, sGraphPrimary);
							}
						}
					}
				}
			}
			m_mapWsDigraphs.Add(sWs, digraphs);
			m_mapWsMapChars.Add(sWs, mapChars);
//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:WorldPad,代码行数:101,代码来源:ConfiguredExport.cs

示例13: ComputeDepths

 /// <summary>
 /// Compute depths for all dirEdges via breadth-first traversal of nodes in graph.
 /// </summary>
 /// <param name="startEdge">Edge to start processing with.</param>
 // <FIX> MD - use iteration & queue rather than recursion, for speed and robustness
 private void ComputeDepths(DirectedEdge startEdge)
 {
     Set<Node> nodesVisited = new Set<Node>();
     Queue nodeQueue = new Queue();
     Node startNode = startEdge.Node;                 
     nodeQueue.Enqueue(startNode);   
     nodesVisited.Add(startNode);
     startEdge.Visited = true;
     while (nodeQueue.Count != 0)
     {
         Node n = (Node) nodeQueue.Dequeue();                
         nodesVisited.Add(n);
         // compute depths around node, starting at this edge since it has depths assigned
         ComputeNodeDepth(n);
         // add all adjacent nodes to process queue, unless the node has been visited already                
         IEnumerator i = ((DirectedEdgeStar)n.Edges).GetEnumerator();
         while (i.MoveNext()) 
         {
             DirectedEdge de = (DirectedEdge) i.Current;
             DirectedEdge sym = de.Sym;
             if (sym.IsVisited) continue;
             Node adjNode = sym.Node;
             if (!(nodesVisited.Contains(adjNode))) 
             {
                 nodeQueue.Enqueue(adjNode);
                 nodesVisited.Add(adjNode);
             }
         }                
     }
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:35,代码来源:BufferSubgraph.cs

示例14: NeedsGuessesUpdated

		/// <summary>
		/// Return true if the specified paragraph needs its guesses updated when we've changed something about the analyses
		/// or occurrenes of analyses of one of the specified wordforms.
		/// </summary>
		private bool NeedsGuessesUpdated(int hvoPara, Set<int> wordforms)
		{
			int ktagParaSegments = StTxtPara.SegmentsFlid(Cache);
			int ktagSegmentForms = InterlinVc.SegmentFormsTag(Cache);

			ISilDataAccess sda = m_fdoCache.MainCacheAccessor;
			// If we haven't already figured the segments of a paragraph, we don't need to update it; the guesses will
			// get made when scrolling makes the paragraph visible.
			if (!sda.get_IsPropInCache(hvoPara, ktagParaSegments, (int)CellarModuleDefns.kcptReferenceSequence, 0))
				return false;
			int cseg = sda.get_VecSize(hvoPara, ktagParaSegments);
			for (int iseg = 0; iseg < cseg; iseg++)
			{
				int hvoSeg = sda.get_VecItem(hvoPara, ktagParaSegments, iseg);
				int cxfic = sda.get_VecSize(hvoSeg, ktagSegmentForms);
				for (int ixfic = 0; ixfic < cxfic; ixfic++)
				{
					int hvoWfic = sda.get_VecItem(hvoSeg, ktagSegmentForms, ixfic);
					int hvoInstanceOf = sda.get_ObjectProp(hvoWfic, (int) CmAnnotation.CmAnnotationTags.kflidInstanceOf);
					if (hvoInstanceOf == 0)
						continue; // punctuation, doesn't need guess
					if (Cache.GetClassOfObject(hvoInstanceOf) == WfiGloss.kclsidWfiGloss)
						continue; // fully glossed, no need to update.
					if (wordforms.Contains(WfiWordform.GetWordformFromWag(Cache, hvoInstanceOf)))
						return true; // This paragraph IS linked to one of the interesting wordforms; needs guesses updated
				}
			}
			return false; // no Wfics that might be affected.
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:33,代码来源:InterlinDocView.cs

示例15: FixPoint

    /// <summary>
    /// Perform a fixpoint computation over a ser of methods (in general a strongly connected component).
    /// It perform the interprocedural analysis for each method, reanalysing any callers that require updating. 
    /// </summary>
    protected virtual Set<Method> FixPoint()
    {
      Set<Method> analyzed = new Set<Method>();

      Set<Method> methodsInFixPoint = new Set<Method>(methodsToAnalyze);
      while (methodsToAnalyze.Count != 0)
      {
        Method m = methodsToAnalyze[0];
        if (verbose)
          Console.Out.WriteLine("Now Analyzing {0} left: {2} Unsafe? {1} ", m.GetFullUnmangledNameWithTypeParameters(), IsUnsafe(m), methodsToAnalyze.Count);

        if (PointsToAnalysis.debug)
        {
          if (m.FullName.Contains("PaintDotNet.GradientRenderer.Render"))
          {
            //    System.Diagnostics.Debugger.Break();
          }
        }

        analyzed.Add(m);

        methodsToAnalyze.RemoveAt(0);

        bool hasChanged = false;
        // Perform the IntraProcedural of the Method 
        // if it wasn't analyzed before
        // Analyzed means that it was complety analyzed in a previous 
        // fix point computation, so its value is not going to change
        if (!WasAnalyzed(m))
          hasChanged = AnalyzeMethod(m);
        //else
        //    Console.Out.WriteLine(" was already analyzed!");
        // If a method changes, we have to reanalyze the callers
        if (hasChanged && IsAnalyzable(m))
        {
          // I should change this to cg.Callers(m)....
          foreach (Method caller in GetCallers(m))
          {
            if (!methodsToAnalyze.Contains(caller))
            {
              //if (alreadyAnalyzedMethods.Contains(caller) || methodsInFixPoint.Contains(caller))
              if (methodsInFixPoint.Contains(caller))
              {
                methodsToAnalyze.Add(caller);
                if (verbose)
                  Console.Out.WriteLine("\t reanalyzing {0}", caller.FullName);
              }
            }
          }
          //foreach (Method caller in GetCallers(m))
          //{
          //    Console.Out.WriteLine("\t Reanalyzing {0}", caller.GetFullUnmangledNameWithTypeParameters());
          //}
        }

        #region debugging, Delete this!
        if (verbose || debug)
        {
          counter++;
          if (counter % 1000 == 0)
          {
            Console.Out.WriteLine("Now Analyzing {0} Unsafe? {1} {2} To Analize: {3}",
                m.GetFullUnmangledNameWithTypeParameters(),
                IsUnsafe(m), counter, methodsToAnalyze.Count);
            foreach (Method mt in methodsToAnalyze)
            {
              Console.Out.WriteLine("\t  {0}", mt.GetFullUnmangledNameWithTypeParameters());
            }
          }
        }
        #endregion
      }
      return analyzed;
    }
开发者ID:hesam,项目名称:SketchSharp,代码行数:78,代码来源:PointsToAnalysis.cs


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