int main()
{
  LinkedList list = newLinkedList(); 
  LinkedList emptyList = newLinkedList();

  Student student1 = { "aaa111", 0.0};
  Student student2 = { "bbb111", 3.5};
  Student student3 = { "ccc111", 2.0};
  Student student4 = { "ddd111", 4.0};
  Student student5 = { "eee111", 2.5};

  insertOrderedLL(list, student1);
  insertOrderedLL(list, student2);
  insertOrderedLL(list, student3);
  insertOrderedLL(list, student4);
  insertOrderedLL(list, student5);

  double dHighestGPA = getHighGPA(list->pHead);
  printf("%.2lf\n\n", dHighestGPA);

  dHighestGPA = getHighGPA(emptyList->pHead);
  printf("%.2lf\n\n", dHighestGPA);

  NodeLL *pLastNode = last(list->pHead);
  printf("%s\n\n", pLastNode->student.szAbc123Id);
  
  pLastNode = last(emptyList->pHead);
  if(pLastNode == NULL) {
    printf("Success!\n");
  }
}
Esempio n. 2
0
void init() {
//	printf("%d \n", sizeof(Trie3));
	initDocumentDescriptorPool();
	initLinkedListDefaultPool();
	lazy_list = newLinkedList();
	queries = newLinkedList();
//	int numCPU = sysconf(_SC_NPROCESSORS_ONLN);
//	ht = new_Hash_Table();
	//THREAD_ENABLE=1;
	trie = newTrie();
//	int i = 0;
	eltire = newTrie3();
//	dtrie = newTrie();
//	docList = newLinkedList();
}
Esempio n. 3
0
ProgramOption newProgramOptionWithName(const int optionIndex, const char* name,
  const char* help, boolByte hasShortForm, ProgramOptionType type,
  ProgramOptionArgumentType argumentType) {
  ProgramOption option = (ProgramOption)malloc(sizeof(ProgramOptionMembers));

  option->index = optionIndex;
  option->name = newCharStringWithCString(name);
  option->help = newCharStringWithCString(help);
  option->hasShortForm = hasShortForm;
  option->hideInHelp = false;

  option->type = type;
  switch(type) {
    case kProgramOptionTypeEmpty:
      // Nothing needed here
      break;
    case kProgramOptionTypeString:
      option->_data.string = newCharString();
      break;
    case kProgramOptionTypeNumber:
      option->_data.number = 0.0f;
      break;
    case kProgramOptionTypeList:
      option->_data.list = newLinkedList();
      break;
    default:
      logInternalError("ProgramOption with invalid type");
      break;
  }
  option->argumentType = argumentType;
  option->enabled = false;

  return option;
}
Esempio n. 4
0
void addAllLL2(LinkedList* recepteur, LinkedList* source) {
    printf("taille de la recepteur: %lu et du source:%lu\n",recepteur->longueur,source->longueur);
    afficheLinkedList(recepteur, 1);
    afficheLinkedList(source, 1);
    if (source->longueur == 0) {
        afficheLinkedList(recepteur, 1);
        return;
    }
    if (recepteur->longueur == 0) {
        recepteur->dernier=source->dernier;
        recepteur->suiv=source->suiv;
        recepteur->longueur=source->longueur;
        recepteur->valeur = source->valeur;
        afficheLinkedList(recepteur, 1);
        return;
        
    }
    LinkedList* nouv = newLinkedList();
    nouv->valeur = source->valeur;
    nouv->suiv = source->suiv;
    nouv->prec = source->prec;
    nouv->longueur = source->longueur;
    nouv->dernier = source->dernier;
    
    recepteur->dernier->suiv = nouv;
    nouv->prec = recepteur->dernier;
    recepteur->dernier = nouv->dernier;
    recepteur->longueur += nouv->longueur;
    afficheLinkedList(recepteur, 1);
    return;
}
Esempio n. 5
0
Command* listToCommand(const List* list)
{
  ListNode* node;
  Command* command;

  if(list == NULL || linkedListSize(list) == 0)
    return NULL;

  command = (Command*) malloc( sizeof(Command) );
  command->command = newLinkedList();

  node = list->head;

  /* each argument is just inserted into the command's argument list */
  while(node != NULL)
  {
    linkedListInsert(command->command, node->data);
    node = node->next;
  }

  command->infile = NULL;
  command->outfile = NULL;

  return command;
}
Esempio n. 6
0
graph* newGraph(){
	graph* g;
	g = (graph *)malloc(sizeof(graph));
	g->vertices = newLinkedList();

	return g;
}
Esempio n. 7
0
static int _testLinkedListWithEmptyList(void) {
  CharString** arr;
  LinkedList l = newLinkedList();
  arr = (CharString**)linkedListToArray(l);
  assertIsNull(arr);
  return 0;
}
Esempio n. 8
0
void addLL(LinkedList* liste, void* element, unsigned long index) {
    if (index == 0) {
        addFirstLL(liste, element);
        return;
    }
    unsigned long l = sizeLL(liste);
    if (index == l) {
        addLastLL(liste, element);
        return;
    }
    if (index > l) {
        printf("list out of bounds : %lu (taille : %lu)", index, l);
        exit(1);
    }
    liste->longueur++;
    LinkedList* position = liste->suiv;
    for (unsigned long i = 1; i < index; i++) {
        position = position->suiv;
    }
    LinkedList* nouv = newLinkedList();
    nouv->valeur = element;
    nouv->prec = position->prec;
    nouv->suiv = position;
    (position->prec)->suiv = nouv;
    position->prec = nouv;
}
Esempio n. 9
0
linkedList* variableOrdering(graph *g,int choice){
     
     item *currItem;
     linkedList *orderedList;
     vertex *v;
     int i;
     
     breakCycles(g);
                   
     resetWeights(g); 
     computeWeights(g);
     genericSuccessorsOrdering(g, choice);
     orderByWeights(g->vertices);
     resetVisited(g); 
     orderedList= newLinkedList();
     
     currItem = (g-> vertices)->head;
     while (currItem!= NULL) {
           if ((currItem->vert)->visited == 0) visit(currItem->vert,orderedList);
           currItem = currItem->next;
     }
     
     return orderedList;
     
}
Esempio n. 10
0
static LinkedList _getTestSuites(void) {
  LinkedList internalTestSuites = newLinkedList();
  linkedListAppend(internalTestSuites, addAudioClockTests());
  linkedListAppend(internalTestSuites, addAudioSettingsTests());
  linkedListAppend(internalTestSuites, addCharStringTests());
#if USE_NEW_FILE_API
  linkedListAppend(internalTestSuites, addFileTests());
#endif
  linkedListAppend(internalTestSuites, addFileUtilitiesTests());
  linkedListAppend(internalTestSuites, addLinkedListTests());
  linkedListAppend(internalTestSuites, addMidiSequenceTests());
  linkedListAppend(internalTestSuites, addMidiSourceTests());
  linkedListAppend(internalTestSuites, addPlatformUtilitiesTests());
  linkedListAppend(internalTestSuites, addPluginTests());
  linkedListAppend(internalTestSuites, addPluginChainTests());
  linkedListAppend(internalTestSuites, addPluginPresetTests());
  linkedListAppend(internalTestSuites, addProgramOptionTests());
  linkedListAppend(internalTestSuites, addSampleBufferTests());
  linkedListAppend(internalTestSuites, addSampleSourceTests());
  linkedListAppend(internalTestSuites, addStringUtilitiesTests());
  linkedListAppend(internalTestSuites, addTaskTimerTests());

  linkedListAppend(internalTestSuites, addAnalysisClippingTests());
  linkedListAppend(internalTestSuites, addAnalysisDistortionTests());
  linkedListAppend(internalTestSuites, addAnalysisSilenceTests());

  return internalTestSuites;
}
Esempio n. 11
0
static int _testForeachOverEmptyList(void) {
  LinkedList l = newLinkedList();
  linkedListForeach(l, _linkedListEmptyCallback, NULL);
  assertIntEquals(_gNumForeachCallbacksMade, 0);
  freeLinkedList(l);
  return 0;
}
Esempio n. 12
0
LinkedList getVst2xPluginLocations(CharString currentDirectory) {
  LinkedList locations = newLinkedList();
  CharString locationBuffer;
  const char* programFiles = (!isExecutable64Bit() && isHost64Bit()) ?
    kPlatformWindows32BitProgramFolder : kPlatformWindowsProgramFolder;

  linkedListAppend(locations, currentDirectory);

  locationBuffer = newCharString();
  snprintf(locationBuffer->data, (size_t)(locationBuffer->length), "C:\\VstPlugins");
  linkedListAppend(locations, locationBuffer);

  locationBuffer = newCharString();
  snprintf(locationBuffer->data, (size_t)(locationBuffer->length), "%s\\VstPlugIns", programFiles);
  linkedListAppend(locations, locationBuffer);

  locationBuffer = newCharString();
  snprintf(locationBuffer->data, (size_t)(locationBuffer->length), "%s\\Common Files\\VstPlugIns", programFiles);
  linkedListAppend(locations, locationBuffer);

  locationBuffer = newCharString();
  snprintf(locationBuffer->data, (size_t)(locationBuffer->length), "%s\\Steinberg\\VstPlugIns", programFiles);
  linkedListAppend(locations, locationBuffer);

  return locations;
}
LinkedList getDefaultArguments(const char *testName) {
  LinkedList arguments = newLinkedList();
  appendItemToList(arguments, "--log-file");
  appendItemToList(arguments, _getTestOutputFilename(testName, "txt"));
  appendItemToList(arguments, "--output");
  appendItemToList(arguments, _getTestOutputFilename(testName, "pcm"));
  return arguments;
}
Esempio n. 14
0
static int _testNewLinkedList(void) {
  LinkedList l = newLinkedList();
  assertNotNull(l);
  assertIsNull(l->nextItem);
  assertIntEquals(linkedListLength(l), 0);
  assert(l->item == NULL);
  freeLinkedList(l);
  return 0;
}
Esempio n. 15
0
/******************** newSimulation ******************************
 Simulation newSimulation()
 Purpose:
     Creates a new Simulation.
 Parameters:
     N/A
 Notes:
    1. Initially sets sim variables to 0
    2. Uses newLinkedList function
 *****************************************************************/
Simulation newSimulation()
{
    Simulation sim = (Simulation) malloc(sizeof(SimulationImp));
    sim->iClock = 0;
    sim->lSystemTimeSum = 0;
    sim->lWidgetCount = 0;
    sim->eventList = newLinkedList();
    return sim;
}
Esempio n. 16
0
static int _testFillEventsSequentially(void) {
  MidiSequence m = newMidiSequence();
  MidiEvent e = newMidiEvent();
  MidiEvent e2 = newMidiEvent();
  LinkedList l = newLinkedList();
  e->status = 0xf7;
  e->timestamp = 100;
  e2->status = 0xf7;
  e2->timestamp = 300;
  appendMidiEventToSequence(m, e);
  appendMidiEventToSequence(m, e2);
  _assert(fillMidiEventsFromRange(m, 0, 256, l));
  _assertIntEquals(numItemsInList(l), 1);
  l = newLinkedList();
  _assertFalse(fillMidiEventsFromRange(m, 256, 256, l));
  _assertIntEquals(numItemsInList(l), 1);
  return 0;
}
Esempio n. 17
0
static int _testAppendNullItemToList(void) {
  LinkedList l = newLinkedList();
  linkedListAppend(l, NULL);
  assertIsNull(l->item);
  assertIsNull(l->nextItem);
  assertIntEquals(linkedListLength(l), 0);
  freeLinkedList(l);
  return 0;
}
Esempio n. 18
0
MidiSequence newMidiSequence(void) {
  MidiSequence midiSequence = malloc(sizeof(MidiSequenceMembers));

  midiSequence->midiEvents = newLinkedList();
  midiSequence->_lastEvent = midiSequence->midiEvents;
  midiSequence->_lastTimestamp = 0;
  midiSequence->numMidiEventsProcessed = 0;

  return midiSequence;
}
Esempio n. 19
0
/*************************** newListFromInput **********************************
LinkedList newListFromInput()
Purpose:
	Goes through the input file, for each line, creates a widget and an 
	arrival event for that widget and insert it in a list.
Parameters:
Returns:
	Functionally:
		A LinkedList variable populated from the input.
Notes:
*******************************************************************************/
LinkedList newListFromInput()
{
	/***variables***/
	char szInputBuffer[MAX_LINE_SIZE + 1];
	Widget widget;
	Event arrival;
	LinkedList list;
	int iClock, iNextArrival, iScanfCnt;
	
	//allocate list
	list = newLinkedList();
	
	iClock = 0; 
	while (fgets(szInputBuffer, MAX_LINE_SIZE, pInputFile) != NULL 
			&& iClock <= MAX_ARRIVAL_TIME) //for each line of the input file
	{	
		if (szInputBuffer[0] == '\n') //if line is empty, ignore
		{
			continue;
		}
	
		//populate the widget variable with data from input line and current clock
		iScanfCnt = sscanf(szInputBuffer, "%ld %d %d %d\n", &(widget.lWidgetNr), 
							&(widget.iStep1tu), &(widget.iStep2tu), &iNextArrival);
		widget.iArrivalTime = iClock;
	
		if (iScanfCnt < 4) //if there's less than 4 tokens in the line
		{
			ErrExit(ERR_BAD_INPUT, "%sExpected 4 tokens,received %d successful values\n",
					szInputBuffer, iScanfCnt);
			continue;
		}
	
		if (widget.iStep1tu < 0 || widget.iStep2tu < 0 || iNextArrival < 0)
		//if the values are negative values
		{
			ErrExit(ERR_BAD_INPUT, 
					"%sStep1tu, Step2tu, and DeltaArrival cannot be negative values.\n",
					szInputBuffer, iScanfCnt);
			continue;
		}
	
		//populate the arrival Event variable
		arrival.iEventType = EVT_ARRIVAL;
		arrival.iTime = iClock;
		arrival.widget = widget;
		//insert it into the list
		insertOrderedLL(list, arrival);
		//increment clock for next input line (next widget)
		iClock += iNextArrival;
	}
	
	return list;
}
Esempio n. 20
0
static int _testFillEventsFromEmptyRange(void) {
  MidiSequence m = newMidiSequence();
  MidiEvent e = newMidiEvent();
  LinkedList l = newLinkedList();
  e->status = 0xf7;
  e->timestamp = 100;
  appendMidiEventToSequence(m, e);
  _assert(fillMidiEventsFromRange(m, 0, 0, l));
  _assertIntEquals(numItemsInList(l), 0);
  return 0;
}
Esempio n. 21
0
static int _testAppendItemToList(void) {
  LinkedList l = newLinkedList();
  CharString c = newCharString();
  charStringCopyCString(c, TEST_ITEM_STRING);
  linkedListAppend(l, c);
  assertNotNull(l->item);
  assertCharStringEquals(((CharString)l->item), TEST_ITEM_STRING);
  assertIsNull(l->nextItem);
  freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString);
  return 0;
}
Esempio n. 22
0
static int _testFillMidiEventsFromRangeStart(void) {
  MidiSequence m = newMidiSequence();
  MidiEvent e = newMidiEvent();
  LinkedList l = newLinkedList();
  e->status = 0xf7;
  e->timestamp = 100;
  appendMidiEventToSequence(m, e);
  _assertFalse(fillMidiEventsFromRange(m, 0, 256, l));
  _assertIntEquals(numItemsInList(l), 1);
  _assertIntEquals(((MidiEvent)l->item)->status, 0xf7)
  return 0;
}
Esempio n. 23
0
vertex* newVertex(int val){
      vertex *curr;
      curr = (vertex *)malloc(sizeof(vertex));
      curr->val = val;
      curr->successors  = newLinkedList();
      curr->visited=0;
      curr->weight = 0;
      curr->nop = 0;
     // curr->id = nodes++;  // debug
      //printf("New node for v%d\n",val);  // debug
      return curr;
}
Esempio n. 24
0
// In both the TestSuite and TestCase objects we assume that we do not need ownership of
// the strings passed in, since they should be allocated on the heap and live for the
// lifetime of the program.
TestSuite newTestSuite(char* name, TestCaseSetupFunc setup, TestCaseTeardownFunc teardown) {
  TestSuite testSuite = (TestSuite)malloc(sizeof(TestSuiteMembers));
  testSuite->name = name;
  testSuite->numSuccess = 0;
  testSuite->numFail = 0;
  testSuite->numSkips = 0;
  testSuite->testCases = newLinkedList();
  testSuite->setup = setup;
  testSuite->teardown = teardown;
  testSuite->onlyPrintFailing = false;
  testSuite->keepFiles = false;
  return testSuite;
}
Esempio n. 25
0
void addLastLL(LinkedList* liste, void* element) {
    if (sizeLL(liste) == 0) {
        liste->longueur++;
        liste->valeur = element;
    } else {
        liste->longueur++;
        LinkedList* nouv = newLinkedList();
        nouv->valeur = element;
        (liste->dernier)->suiv = nouv;
        nouv->prec = liste->dernier;
        liste->dernier = nouv;
    }
}
Esempio n. 26
0
int main()
{
	LinkedList ll;
	ll = newLinkedList();
	procedures(ll);

	printf("\n\nDestructing List:\n");
	deleteLinkedList(ll);
	printList(ll);
	
	system("pause");
	return 0;
}
Esempio n. 27
0
static int _testNumItemsInList(void) {
  CharString c;
  int i;
  LinkedList l = newLinkedList();
  for(i = 0; i < 100; i++) {
    c = newCharString();
    charStringCopyCString(c, TEST_ITEM_STRING);
    linkedListAppend(l, c);
  }
  assertIntEquals(linkedListLength(l), 100);
  freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString);
  return 0;
}
Esempio n. 28
0
static int _testForeachOverUserData(void) {
  LinkedList l = newLinkedList();
  CharString c = newCharString();

  charStringCopyCString(c, TEST_ITEM_STRING);
  linkedListAppend(l, c);
  linkedListForeach(l, _linkedListUserDataCallback, c);
  assertIntEquals(_gNumForeachCallbacksMade, 1);
  assert(_gForeachCallbackOk);

  freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString);
  return 0;
}
Esempio n. 29
0
Arbre* newFeuille(char caractere, unsigned long poids){
    Arbre* arbre = malloc(sizeof(Arbre));
    arbre->poids = poids;
    arbre->droit = NULL;
    arbre->gauche = NULL;
    arbre->lettre = caractere;
    arbre->codage_moyen = 0;
    arbre->profondeur = 0;
    arbre->codage_caracteres = newTabOfPoint(256);
    TabOfPoint_put(arbre->codage_caracteres, newLinkedList(), arbre->lettre+128);
    arbre->liste_caracteres = newTabOfChar(1);
    TabOfChar_put(arbre->liste_caracteres, arbre->lettre, 0);
    return arbre;
}
Esempio n. 30
0
static int _testLinkedListToArray(void) {
  LinkedList l = newLinkedList();
  CharString* arr;

  appendItemToList(l, newCharStringWithCString("one"));
  appendItemToList(l, newCharStringWithCString("two"));
  arr = (CharString*)linkedListToArray(l);
  assertNotNull(arr);
  assertCharStringEquals((CharString)arr[0], "one");
  assertCharStringEquals((CharString)arr[1], "two");
  assertIsNull(arr[2]);

  return 0;
}