Exemple #1
0
XmlDoc & XmlDoc::seek(const QString & chemin, bool newElt, bool root)
{
    if(root) begin();
    bool controle = true;
    QList<QString> list(chemin.split("/"));
    for(QList<QString>::const_iterator i = list.cbegin(); controle && i != list.cend(); ++i)
    {
        QList< TreeItem<XmlElement> *>::const_iterator j = childs().cbegin();
        while(j != childs().cend() && (*j)->data().name() != *i) ++j;
        if(j == childs().cend())
        {
            controle = false;
            if(newElt)
            {
                XmlElement elt;
                for(; i != list.cend(); ++i)
                {
                    elt.setName(*i);
                    addChild(elt);
                }
            }
            else
            {
                m_i = m_root;
            }
        }
        else
        {
            m_i = *j;
        }
    }
    return *this;
}
Exemple #2
0
void CALLBACK LibDir(PPBORCA_DIRENTRY pEntry, void * lpData)
{
	MSXML2::IXMLDOMElementPtr childs((MSXML2::IXMLDOMElement *) lpData);
	
	MSXML2::IXMLDOMElementPtr object = childs->ownerDocument->createElement("object");
	
	object->setAttribute(_bstr_t("name"), _bstr_t(pEntry->lpszEntryName));
	object->setAttribute(_bstr_t("comment"), _bstr_t(pEntry->szComments));

	char lsnumber[30] = {0};
	itoa(pEntry->otEntryType, lsnumber, 10);
	object->setAttribute(_bstr_t("type"), _bstr_t(lsnumber));
	
	object->setAttribute(_bstr_t("typename"), 
		_bstr_t(orca.convertObjectType(pEntry->otEntryType)));

	itoa(pEntry->lEntrySize, lsnumber, 10);
	object->setAttribute(_bstr_t("size"), _bstr_t(lsnumber));

	tm *ptime = localtime(&pEntry->lCreateTime);
	strftime(lsnumber, sizeof(lsnumber), "%d.%m.%y %H:%M:%S", ptime);
	object->setAttribute(_bstr_t("createtime"), _bstr_t(lsnumber));

	childs->appendChild(object);
	object = NULL;
}
QXmlTreeNode* QXmlTreeNode::child(const QDomNode &node)
{
    unsigned int childCount = childs();
    for (unsigned int i = 0; i < childCount; ++i)
    {
        QXmlTreeNode* childNode(m_childItems[i]);
        if (childNode->xmlNode() == node)
            return childNode;
        // Depth Search
        childNode = childNode->child(node);
        if (childNode)
            return childNode;
    }
    return 0;
}
Exemple #4
0
int main(void) {

    short int i;

    srand(time(NULL));

    initialize();

    puts("To πρόγραμμα εξυπηρετεί Χ αιτήσεις όπου Χ ένας τυχαίος αριθμός");
    puts("αιτήσεων ο οποίος δημιουργήθηκε σε n δευτερόλεπτα.");
    puts("\nΣημείωση:");
    puts("Ο χρόνος που θα δημιουργεί αιτήσεις δεν εχει σχέση με τον χρόνο");
    puts("που θα εκτελείται το πρόγραμμα");
    puts("\nΕισήγαγε τα n δευτερόλεπτα που το πρόγραμμα θα δημιουργεί");
    puts("αιτήσεις:");

    /* Εισήγαγε μη μηδενική τιμή */
    do {
	scanf("%d", &EndTime);
    } while (EndTime < 0);

    for (i = 0; i < 10; i++) {
	pid_c[i] = fork();
	switch (pid_c[i]) {
	    case 0:
		childs(i);
		flag_c = TRUE;
		break; //case break
	    case -1:
		perror("Fork SSTF");
		return Error;
	}
	//Αν είσαι παιδί κάνε break απ'το for
	if (flag_c == TRUE) {
	    break;
	}
    }

    if (flag_c == FALSE) {
	father();
    }

    return (EXIT_SUCCESS);
}
Exemple #5
0
    std::vector<Board<size_board>> a_star_search() {
        int cpt = 0;
        Node<size_board> current_node;
        std::priority_queue<Node<size_board>> heap;
        std::set<Board<size_board>> visited;
        std::map<Board<size_board>, Board<size_board>> parent_node;

        std::vector<Board<size_board>> shortest_path;
        Board<size_board> parc;

        heap.push(init_state);

        do {
            current_node = heap.top();
            heap.pop();
            if (visited.find(current_node.board) != visited.end()) {
                continue;
            }
            visited.insert(current_node.board);

            for (auto c : childs(current_node)) {
                if (visited.find(c.board) == visited.end()) {
                    parent_node[c.board] = current_node.board;
                    heap.push(c);
                }
            }
        } while (!(heap.top().board.is_solved()));


        parc = heap.top().board;
        shortest_path.push_back(parc);
        while (parc != init_state.board) {
            parc = parent_node[parc];
            shortest_path.push_back(parc);
            cpt++;
        }
        return shortest_path;
    }
Exemple #6
0
CGraph* CreateRandomAndSpecificForIDNetGraph(int num_nodes,
  int num_indep_nodes, int max_size_family)
{
  PNL_CHECK_LEFT_BORDER(num_nodes, 10);
  PNL_CHECK_RANGES(num_indep_nodes, 1, num_nodes-1);
  PNL_CHECK_RANGES(max_size_family, 2, num_nodes);
  
  int i, j, k;
  
  CGraph *pGraph = CGraph::Create(0, NULL, NULL, NULL);
  PNL_CHECK_IF_MEMORY_ALLOCATED(pGraph);
  
  srand((unsigned int)time(NULL));
  
  pGraph->AddNodes(num_nodes);
  
  int num_parents;
  int ind_parent;
  intVector prev_nodes(0);
  for (i = num_indep_nodes; i < num_nodes; i++)
  {
    prev_nodes.resize(0);
    for (j = 0; j < i; j++)
      prev_nodes.push_back(j);
    
    num_parents = rand() % (max_size_family - 1);
    num_parents += 1;
    num_parents = (num_parents > i) ? i : num_parents;
    
    for (j = 0; j < num_parents; j++)
    {
      ind_parent = rand() % prev_nodes.size();
      pGraph->AddEdge(prev_nodes[ind_parent], i, 1);
      prev_nodes.erase(prev_nodes.begin() + ind_parent);
    }
  }
  
  intVector parents(0);
  intVector childs(0);
  for (i = 0; i < num_nodes; i++)
  {
    if (pGraph->GetNumberOfChildren(i) == 0)
    {
      pGraph->GetParents(i, &parents);
      for (j = 0; j < parents.size(); j++)
      {
        pGraph->GetChildren(parents[j], &childs);
        for (k = 0; k < childs.size(); k++)
          if ((childs[k] != i) && 
            (pGraph->GetNumberOfChildren(childs[k]) == 0) &&
            (pGraph->GetNumberOfParents(childs[k]) == 1))
          {
            if (i < childs[k])
            {
              pGraph->RemoveEdge(parents[j], childs[k]);
              pGraph->AddEdge(i, childs[k], 1);
            }
            else
            {
              pGraph->AddEdge(childs[k], i, 1);
            }
          }
      }
    }
  }
  
  return pGraph;
}