def layerEgrodic(self):
     self.ls = []
     import queue
     queue = queue.Queue()
     queue.enqueue(self.root)
     while queue.size() != 0:
         curr_node = queue.dequeue()
         self.ls.append(curr_node.key)
         if curr_node.left != None: queue.enqueue(curr_node.left)
         if curr_node.right != None: queue.enqueue(curr_node.right)
     return self.ls
Exemple #2
0
def startDlcScan(queue):
    dlcStatus = Status.create(queue.size() * 0x200, 'DLC Scan')
    #scanDLC(id)
    threads = []
    for i in range(scrapeThreads):
        t = threading.Thread(target=scanDLCThread, args=[queue, dlcStatus])
        t.start()
        threads.append(t)

    for t in threads:
        t.join()
    dlcStatus.close()
Exemple #3
0
 def minMutation(self, start, end, bank):
     """
     :type start: str
     :type end: str
     :type bank: List[str]
     :rtype: int
     """
     if start==end: return 0
     
     charSet=['A', 'C', 'G', 'T']
     level=0
     visitedw=[]
     q=queue.Queue()
     q.put(start)
     visited.put(start)
     
     while not q.empty(): 
         size=q.qsize()
         while size>0: 
             
             curr=q[0]
             if curr==end: return level
             
             curr=
     
     
     while(!queue.isEmpty()) {
         int size = queue.size();
         while(size-- > 0) {
             String curr = queue.poll();
             if(curr.equals(end)) return level;
             
             char[] currArray = curr.toCharArray();
             for(int i = 0; i < currArray.length; i++) {
                 char old = currArray[i];
                 for(char c: charSet) {
                     currArray[i] = c;
                     String next = new String(currArray);
                     if(!visited.contains(next) && bankSet.contains(next)) {
                         visited.add(next);
                         queue.offer(next);
                     }
                 }
                 currArray[i] = old;
             }
         }
         level++;
     }
Exemple #4
0
def breadth_first_order(tnode):
    """
    Display the nodes of a tree in breadth-first-order.
    :param tnode: a primitive tree
    :return: nothing
    """
    nodes = Queue.create()
    Queue.enqueue(nodes, tnode)
    order = Queue.create()
    #
    while Queue.size(nodes) > 0:
        current = Queue.dequeue(nodes)
        if current is not None:
            Queue.enqueue(order, tn.get_data(current))
            Queue.enqueue(nodes, tn.get_left(current))
            Queue.enqueue(nodes, tn.get_right(current))

    while not Queue.is_empty(order):
        n = Queue.dequeue(order)
        print(n, end=" ")
Exemple #5
0
def scanDLCThread(queue, dlcStatus):
    while queue.size() > 0 and Config.isRunning:
        id = queue.shift()
        if id:
            scanDLC(id, False, dlcStatus)