WikiCrawler/MediaWiki/WikimediaCategoryTree.cs
/// <summary>
/// Returns true if the specified category has the parent category as a parent.
/// </summary>
Returns true if the specified category has the parent category as a parent.
Returns true if the specified category has the parent category as a parent .
public bool HasParent(string category, string findParent)
		{
			Queue<string> toCheck = new Queue<string>();
			HashSet<string> alreadyChecked = new HashSet<string>();
			toCheck.Enqueue(category);
			while (toCheck.Count > 0)
			{
				string checkCat = toCheck.Dequeue();
				if (!s_CategoriesByCategory.ContainsKey(checkCat)) continue;
				foreach (string parent in s_CategoriesByCategory[checkCat])
				{
					if (!alreadyChecked.Contains(parent))
					{
						if (parent == findParent)
						{
							return true;
						}
						toCheck.Enqueue(parent);
						alreadyChecked.Add(parent);
					}
				}
			}
			return false;
		}
public bool HasParent ( string category , string findParent ) { Queue < string > toCheck = new Queue < string > ( ) ; HashSet < string > alreadyChecked = new HashSet < string > ( ) ; toCheck . Enqueue ( category ) ; while ( toCheck . Count > 0 ) { string checkCat = toCheck . Dequeue ( ) ; if ( ! s_CategoriesByCategory . ContainsKey ( checkCat ) ) continue ; foreach ( string parent in s_CategoriesByCategory [ checkCat ] ) { if ( ! alreadyChecked . Contains ( parent ) ) { if ( parent == findParent ) { return true ; } toCheck . Enqueue ( parent ) ; alreadyChecked . Add ( parent ) ; } } } return false ; }
Returns true if the specified category has the parent category as a parent.
Returns true if the specified category has the parent category as a parent .
category
string
findParent
string