Beispiel #1
0
void addToRandomList(char *fName, int browserLoc)
{
	if(soundMode == SOUND_NEXTFILE) // we let oneshot add because sometimes that's the default, and we want it to stay in the history
		return;
	
	if(!isValidRandomList())
	{
		createRandomList();
		strcpy(history[0].fileName, fName);
		history[0].browserLoc = browserLoc;
		return;
	}
	
	h_position++;
	if(h_count == h_position) // we've hit max
	{
		h_count++;
		
		history = (PLAYLIST_LIST *)trackRealloc(history, sizeof(PLAYLIST_LIST) * h_count);
	}
	
	strcpy(history[h_position].fileName, fName);
	history[h_position].browserLoc = browserLoc;
	
	h_max = h_position + 1; // fake end
}
int main()
{
    
    ListNode * l = createRandomList();
    Solution s = Solution();
    printList(l, NULL);
    std::cout<<"sorted:"<< '\n';
    printList(s.sortList(l), NULL);
    return 0;
}
/*
 *This function create a list and after invert it on a another one
 * */
void invertList()
{
	/*Creating the first list*/
	nodePointer list = createRandomList(10);
	printf("\nThe origin list is: ");
	printList(list);
	/*Creating a new list inverting the first one*/
	nodePointer invertedList = NULL;
	nodePointer currentNode = list;
	while(currentNode != NULL){
		nodePointer tempNode = currentNode->nextNode;
		currentNode->nextNode = NULL;
		currentNode->nextNode = invertedList;
		invertedList = currentNode;
		currentNode = tempNode;
		
	}
	printf("\nThe inverted list is: ");
	printList(invertedList);
	
	
}