コード例 #1
0
ファイル: bfs.cs プロジェクト: HellishTide/education
        public string Bfs_Search(string name)
        {
            if (DictionaryGraph.Count != 0)
            {
                AddToQueue(name);
            }
            else
            {
                throw new ArgumentNullException();
            }

            while (SearchQueue.Count != 0)
            {
                string person = SearchQueue.Dequeue();

                if (!Searched.Contains(person))
                {
                    if (person == target)
                    {
                        return(String.Format("Find {0}", person));
                    }
                    else
                    {
                        Searched.Add(person);
                        AddToQueue(person);
                    }
                }
            }
            return(String.Format("Not found"));
        }
コード例 #2
0
ファイル: bfs.cs プロジェクト: HellishTide/education
 public void AddToQueue(string name)
 {
     if (DictionaryGraph.ContainsKey(name))
     {
         DictionaryGraph[name].ForEach(delegate(String element)
         {
             SearchQueue.Enqueue(element);
         });
         return;
     }
 }
コード例 #3
0
        protected override void BeginProcessing()
        {
            this.shouldInclude = CreateShouldIncludeList();

            PartQuery initialQuery = new PartQuery(this);

            this.queue = new SearchQueue();

            queue.AddRange(this.SearchDirectories.Select(searchDir => new SearchState(initialQuery, searchDir, 0)));

            base.BeginProcessing();
        }
コード例 #4
0
        public WordSearch(string searchText, SearchCompleteHandlerDelegate handler, bool clearQueue = true)
        {
            SearchText            = searchText;
            SearchCompleteHandler = handler;

            lock (SearchQueueMutex)
            {
                if (clearQueue)
                {
                    SearchQueue.Clear();
                }
                SearchQueue.Enqueue(this);
            }

            if (MasterStartNotifier != null)
            {
                MasterStartNotifier.Set();
            }
            Debug.WriteLine("Search queued");
        }
コード例 #5
0
    static public void GetPath(NodeTD startN, NodeTD endN, NodeTD blockN, NodeTD[] graph, SetPathCallbackTD callBackFunc, bool urgent)
    {
        CheckInit();

        if (!searching)
        {
            //commence search
            Search(startN, endN, blockN, graph, callBackFunc);
        }
        else
        {
            //if a serach is in progress, put current request into a list
            SearchQueue q = new SearchQueue(startN, endN, blockN, graph, callBackFunc);
            if (urgent)
            {
                queue.Insert(0, q);
            }
            else
            {
                queue.Add(q);
            }
        }
    }
コード例 #6
0
ファイル: PathFinder.cs プロジェクト: GameDevUnity/tdtk
	static public void GetPath(Node startN, Node endN, Node blockN, Node[] graph, SetPathCallback callBackFunc, bool urgent){
		CheckInit();
		
		if(!searching){
			//commence search
			Search(startN, endN, blockN, graph, callBackFunc);
		}
		else{
			//if a serach is in progress, put current request into a list
			SearchQueue q=new SearchQueue(startN, endN, blockN, graph, callBackFunc);
			if(urgent) queue.Insert(0, q);
			else queue.Add(q);
		}
	}
コード例 #7
0
        /// <summary>
        /// Initialization routine
        /// </summary>
        private void Initialize()
        {
            // load the environment configuration file from UtilsInternal
            var sr                    = new FileSettingsReader(ConfigurationManager.AppSettings["ConfigRelativePath"] + Path.DirectorySeparatorChar + environmentName + ".config");
            var certThumbprint        = sr.ReadValue(SocialPlusCertThumbprint);
            var clientID              = sr.ReadValue(EmbeddedSocialClientIdSetting);
            var storeLocation         = StoreLocation.CurrentUser;
            var vaultUrl              = sr.ReadValue(SocialPlusVaultUrlSetting);
            ICertificateHelper cert   = new CertificateHelper(certThumbprint, clientID, storeLocation);
            IKeyVaultClient    client = new AzureKeyVaultClient(cert);

            var log      = new Log(LogDestination.Console, Log.DefaultCategoryName);
            var kv       = new KV(log, clientID, vaultUrl, certThumbprint, storeLocation, client);
            var kvReader = new KVSettingsReader(sr, kv);
            IConnectionStringProvider connectionStringProvider = new ConnectionStringProvider(kvReader);
            int queueBatchIntervalMs = int.Parse(sr.ReadValue(ServiceBusBatchIntervalMsSetting));

            // Lots of things need to be created to create an appsManager.
            ICTStoreManager tableStoreManager = new CTStoreManager(connectionStringProvider);
            bool            tableInit         = false;
            Exception       exception         = null;

            try
            {
                // use Task.Run to ensure that the async Initialize routine runs on a threadpool thread
                Task <bool> task = Task <bool> .Run(() => tableStoreManager.Initialize());

                // task.Result blocks until the result is ready
                tableInit = task.Result;
            }
            catch (Exception e)
            {
                exception = e;
            }

            if (tableInit == false)
            {
                string errorMessage = "CTstore version number does not match the expected version number." + Environment.NewLine +
                                      "If your tables are empty, then you probably forgot to provision storage." + Environment.NewLine +
                                      "If not, then you need to convert the data format and update the storage version number.";
                Console.WriteLine(errorMessage);
                if (exception != null)
                {
                    Console.WriteLine("Exception message:" + exception.Message);
                }

                Environment.Exit(0);
            }

            ICBStoreManager blobStoreManager = new CBStoreManager(connectionStringProvider);
            AppsStore       appsStore        = new AppsStore(tableStoreManager);
            UsersStore      usersStore       = new UsersStore(tableStoreManager);
            ViewsManager    viewsManager     = new ViewsManager(
                log,
                appsStore,
                usersStore,
                new UserRelationshipsStore(tableStoreManager),
                new TopicsStore(tableStoreManager),
                new TopicRelationshipsStore(tableStoreManager),
                new CommentsStore(tableStoreManager),
                new RepliesStore(tableStoreManager),
                new LikesStore(tableStoreManager),
                new PinsStore(tableStoreManager),
                new BlobsStore(blobStoreManager));
            PushNotificationsManager pushManager = new PushNotificationsManager(log, new PushRegistrationsStore(tableStoreManager), appsStore, viewsManager, connectionStringProvider);

            this.appsManager = new AppsManager(appsStore, pushManager);
            SearchManager       searchManager       = new SearchManager(log, connectionStringProvider);
            PopularUsersManager popularUsersManager = new PopularUsersManager(usersStore);
            QueueManager        queueManager        = new QueueManager(connectionStringProvider, queueBatchIntervalMs);
            SearchQueue         searchQueue         = new SearchQueue(queueManager);

            this.usersManager = new UsersManager(usersStore, pushManager, popularUsersManager, searchQueue);
        }