Example #1
0
/******************************************************************************
 * Add(): add a directory name to the exclude list.
 ******************************************************************************/
void Dir::add  (Settings *settings) {
    bool ok;
    QString s =
        QInputDialog::getText(settings, QObject::tr("Enter a new directory name"),
                              QObject::tr("Directory name:"),QLineEdit::Normal,
                              QString(), &ok);
    //
    // Add new item as specified to exclude list as long as it is in neither the
    // exclude list nor the include list.
    //
    if (ok && !s.isEmpty()
            && !listContains(m_sui->excludeListWidget, s)
            && !listContains(m_sui->includeListWidget, s)) {
        QListWidgetItem *newItem = new QListWidgetItem;
        newItem->setText(s);
        m_sui->excludeListWidget->insertItem(0, newItem);
    }
}
Example #2
0
category_t *dataHandling(char *recipe, char *category, category_t *head)
{
  category_t *current = head;
  recipe_t* recipeNode = newRecipe(recipe, category, NULL);

  if(head == NULL)
  {
    head = newCategory(category, recipeNode, NULL); 
  } 
  else if(listContains(category, head) != NULL)
  {
    current = listContains(category, head);
    stackRecipe(recipeNode, current);
  }
  else
  {
    stackCategory(newCategory(category, recipeNode, NULL), head);
  }
  return head;
}
Example #3
0
e_brainState Brain::runFrame(Brain::s_brainBox situation)
{

  currentSituation.survival = evaluateSurvival(situation);
  currentSituation.work = evaluateWork(situation);
  currentSituation.entertainment = 0;

  e_brainState newState = currentState;

  //std::cout << "Surival rating: " << currentSituation.survival << std::endl;
  //std::cout << "Work rating: " << currentSituation.work << std::endl;
  if ( currentSituation.survival >= currentSituation.work)
    {     
      if (situation.survival.tired < 370)
	newState = e_idle;
      if (situation.survival.thirst > 500)
	newState = e_getWater;
      if (situation.survival.hunger > 500)
	newState = e_getFood;
      if (situation.survival.thirst < 500 && situation.survival.hunger < 500)
	newState = e_idle;
      if (situation.survival.tired > 800)
	newState = e_takeNap;     
    }
  else
    {      
      newState = makeDecision(situation);
    }

  if (situation.exclusions.size() != 0)
    {
      if (listContains(situation.exclusions,newState))
	{
	  newState = e_idle;
	}
    }
  // If the brain has changed its mind since the last time it made a decision
  // it announces that change and applies it to the current decision
  if (newState != currentState)
    {
      std::cout << "Brain state changed" << std::endl;
      std::cout << "New State: " << newState << std::endl;
      currentState = newState;
    }
  return currentState;
}
Example #4
0
Event *event_construct2(Name name, const char *header, float branchLength, Event *parentEvent,
        Event *childEvent, EventTree *eventTree) {
    Event *event;
    event = event_construct(name, header, branchLength, parentEvent, eventTree);
#ifndef NDEBUG
    assert(parentEvent != NULL);
    assert(childEvent != NULL);
    assert(listContains(parentEvent->children, childEvent));
#endif
    listRemove(parentEvent->children, childEvent);
    listAppend(event->children, childEvent);
    childEvent->parent = event;
    childEvent->branchLength = childEvent->branchLength - event->branchLength;
    if (childEvent->branchLength < 0.0) {
        childEvent->branchLength = 0.0;
    }
    return event;
}
Example #5
0
void KateCTagsView::addTagTarget()
{
    KUrl defDir = m_mWin->activeView()->document()->url().directory();

    KFileDialog dialog(defDir, QString(), 0, 0);
    dialog.setMode(KFile::Directory | KFile::Files | KFile::ExistingOnly | KFile::LocalOnly);

    // i18n("CTags Database Location"));
    if (dialog.exec() != QDialog::Accepted) {
        return;
    }

    QStringList urls = dialog.selectedFiles();

    for (int i=0; i<urls.size(); i++) {
        if (!listContains(urls[i])) {
            new QListWidgetItem(urls[i], m_ctagsUi.targetList);
        }
    }
}
Example #6
0
File: main.c Project: Mankee/CS261
int main(){

	struct bag* b = (struct bag*)malloc(sizeof(struct bag));/*Create new bag*/
	initBag(b);/*Initialize*/

    printf("size of list = %d \n", b->lst->size);
    printf("\n");

    addFrontList(b->lst, 3);
    addFrontList(b->lst, 2);
    addBackList(b->lst, 4);
    addBackList(b->lst, 5);
    addBackList(b->lst, 6);
    addFrontList(b->lst, 1);

    int i;
    struct DLink *currentlink = b->lst->head->next;
    for(i = 1; i <= b->lst->size; i++){
            printf("index %d = %d \n", i, currentlink->value);
            currentlink = currentlink->next;
    }
    printf("\n");
    printf("front = %d \n", frontList(b->lst));
    printf("back = %d \n", backList(b->lst));
    printf("is list empty? = %d \n", isEmptyList(b->lst));
    printf("size of list = %d \n", b->lst->size);
    printf("list contains = %d \n", listContains(b->lst, 12));

    printf("\n");
    addToBag(b, 10);
    removeFromBag(b, 1);
    struct DLink *link = b->lst->head->next;
    for(i = 1; i <= b->lst->size; i++){
            printf("index %d = %d \n", i, link->value);
            link = link->next;
    }
    printf("list contains = %d \n", bagContains(b, 100));

    return 0;

}
Example #7
0
/*Function to test if an element exists in the bag
	Pre: b is not null
*/
int bagContains(struct bag* b, TYPE val){
	return listContains(b->l, val);
}