Beispiel #1
0
void LinkedList::printList(ofstream& out){
   out << "ListHead --> (" << listHead->getData() << ", " << listHead->getNext() << ") ";
   ListNode* temp = listHead->getNext();
   while(temp != NULL){
      out << "--> (" << temp->getData() << ", " << temp->getNext() << ") ";
      temp = temp->getNext();
   }
   out << endl;
}
Beispiel #2
0
    /*!
     * Create middlephase jobs according to the \ref BroadPhaseJob.
     *
     * See also \ref MiddlePhaseJobCreator and \ref
     * DetectorDeformManager::pickAlgorithmFor
     */
    void Pipeline::createMiddlePhaseJobs(BroadPhaseJob* broadPhaseJob) {
        List<CollisionPair*>& jobResults = broadPhaseJob->getJobResultsReference();
        for (ListNode<CollisionPair*>* node = jobResults.getFirstNode(); node; node = node->getNext()) {
            CollisionPair* pair = node->getData();

            // TODO make CollisionPair store Proxy pointers.
            //      we usually dont care about the BVs when reading the pairs!!
            Proxy* p1 = pair->bvol1->getHierarchyNode()->getProxy();
            Proxy* p2 = pair->bvol2->getHierarchyNode()->getProxy();

            if (p1->getProxyType() & PROXYTYPE_DEFORMABLE ||
                    p2->getProxyType() & PROXYTYPE_DEFORMABLE) {

                if (mWorld->getUseCollisionCaching()) {
                    bool cacheApplied = mWorld->getCollisionCache()->applyCacheIfAvailable(p1, p2);
                    if (cacheApplied) {
                        continue;
                    }
                }

                DetectorDeformAlgorithm* algorithm = mDetectorDeformManager->pickAlgorithmFor(p1, p2);
                if (algorithm) {
                    // TODO: fix API.
                    //       createCollisionJobFor() uses CollisionPair,
                    //       pickAlgorithmFor() uses two Proxy pointers.
                    //       choose one!
                    algorithm->createCollisionJobFor(*pair);
                }
            }
        }


        mMiddlePhaseJobCreator->createJobs(broadPhaseJob);
    }
Beispiel #3
0
void List::copy(List L){
		Head = NULL;
		ListNode * temp = L.Head;
		while(temp!=NULL){
			this->append(temp->getData());
			temp=temp->getNext();
		}
}
Beispiel #4
0
void List<NODETYPE>::concatenate(List<NODETYPE> &listSecond) {
    ListNode<NODETYPE> *currentPtr = listSecond.firstPtr;

    while (currentPtr != 0) {
        insertAtBack(currentPtr->getData());
        currentPtr = currentPtr->nextPtr;
    }
}
Beispiel #5
0
void List<NODETYPE>::print() const {
    if (isEmpty()) {
        std::cout << "The list is empty\n\n";
        return;
    }

    ListNode<NODETYPE> *currentPtr = firstPtr;

    while (currentPtr != 0) {
        std::cout << currentPtr->getData() << ' ';
        currentPtr = currentPtr->nextPtr;
    }
}
 /*!
  * Start all jobs that have been added to this collection (see \ref addJob).
  * If a job gets added after this point, it will get started immediately
  * (unless \ref resetCompleted has been called in between, which also resets
  * the started flag).
  */
 void ThreadJobCollection::start() {
     if (mStarted) {
         return;
     }
     if (getAllJobsCompleted()) {
         throw Exception("Cannot start collection - all jobs already marked as completed");
     }
     mStarted = true;
     if (mJobs.empty()) {
         allJobsCompleted();
     } else {
         for (ListNode<ThreadJob*>* node = mJobs.getFirstNode(); node; node = node->getNext()) {
             startJob(node->getData());
         }
     }
 }
Beispiel #7
0
void DisplayTrip(const int BORDER,
				  string username,
			      Trip &trip)
{
	const int NUM_OF_OPTIONS = trip.getDestinations().size();

	//Data Structures
	ListNode<tripNode>* 	   selected[NUM_OF_OPTIONS];
	int            parentAr   [NUM_OF_OPTIONS];
	int            dist       [NUM_OF_OPTIONS];

	List<tripNode> destinations;
	avltree<User>  users;

	//Input-Output
	stringstream   ss;
	stringstream   ss2;

	//Variables
	int input;
	int option;
	int index;
	int distance;
	int totalDistance;

	string tripStr;
	string tripName;

	ifstream inFile;
	ofstream outFile;
	User     tempUser;

	tripNode tempTrip;
	tripNode lastTrip;
	tripNode source;
	ListNode<tripNode> *node;

	DWORD mode;

	//Initialize Variables
	input         = 0;
	option        = 1;
	index         = 0;
	distance      = 0;
	totalDistance = 0;

	destinations = trip.getDestinations();
	destinations.to_front();

	CenterStrings(ss, "Press Enter to Select a Trip", BORDER);
	CenterStrings(ss, "Use Up or Down Arrow Keys to Navigate list", BORDER);
	CenterStrings(ss, "Press Ctrl-S to Save and Exit \n\n", BORDER);

	if(destinations.currentNode(source)){
		destinations.to_front();
		source = trip.getSource();
		fastRoute(destinations,
				  source,
				  parentAr,
				  dist,
				  NUM_OF_OPTIONS);
	}

	//Initialize all indices of currentTrip[] to 0 (All options unselected)
	for(int pos = 0; pos < NUM_OF_OPTIONS; pos++){
		selected[pos] = NULL;
	}


	//Main Loop
	while(input != -1)
	{
		// Clear Console.
		system("CLS");

		//Reset Index
		index = 0;
		//PrintInput("MainMenu.txt");
		cout << (MenuString());
		cout << ss.str() << '\n';

		destinations.to_front();

		// Prints Selection.  Passes parameter based on
		// current value of option.
		node = destinations.currentNode();
		while(node != NULL){
			if(index == 0)
			{
				distance = 0;
			}
			else
			{
				distance = node->getData().s.getLocation().distanceTo
													(lastTrip.s.getLocation());
			}
			totalDistance += distance;
			lastTrip = node->getData();

			ss2 << node->getData().s.getStadiumName().str
				<< " | "
				<< node->getData().s.getCity()
				<< ", "
			    << node->getData().s.getState()
				<< " | "
				<< distance
				<< " miles";

			tripStr = NumberedLine(ss2.str(), 5, index + 1, BORDER);
			tripStr += '\n';

			if(selected[index] != NULL || index == option - 1)
			{
					PrintSelection(tripStr);
			}
			else
			{
				cout << tripStr;
			}
			destinations.next(tempTrip);
			node = destinations.currentNode();
			index++;
			ss2.str("");
		}
		cout << "TOTAL DISTANCE: " << totalDistance << " miles\n";
		totalDistance = 0;

		// Get user's key stroke.
		input = PressAnyKey("", mode);


		// If user makes selection (Presses Enter Key)
		tripNode newStop;
		if(input == VK_RETURN)
		{
			if(selected[option - 1] == NULL){
				selected[option - 1] = node;
			}
			else{
				selected[option - 1] = NULL;
			}

		}else if((input == 0x53 && (mode & LEFT_CTRL_PRESSED)) ||
				(input == 0x53 && (mode & RIGHT_CTRL_PRESSED)))
		{
				input = -1;
		}
		else
		{
			if(input == VK_UP){
				ChangeSelection(VK_LEFT, option, NUM_OF_OPTIONS);
			}
			else if(input == VK_DOWN){
				ChangeSelection(VK_RIGHT, option, NUM_OF_OPTIONS);
			}
		}
	}
}
 /*!
  * Called once all jobs in this collection have been completed, i.e.:
  * \li every job that was added using \ref addJob also called \ref setJobCollection
  * \li all jobs that belong to this collection have been added (see \ref setAllJobsAreAdded)
  *
  * Derived classes that reimplement this method \em must call the base
  * implementation!
  */
 void ThreadJobCollection::allJobsCompleted() {
     mAllJobsCompleted = true;
     for (ListNode<ThreadJobCollection*>* node = mStartOnceCompleted.getFirstNode(); node; node = node->getNext()) {
         node->getData()->start();
     }
 }
Beispiel #9
0
int main()
{
	//PlaySound(("NFL_REMIX.wav"), NULL, SND_LOOP | SND_ASYNC);
	List<Souvenir> souvList;
	avltree< TeamContainer<teamName> >    teamAvl;
	avltree< TeamContainer<stadiumName> > stadiumAvl;
	avltree< TeamContainer<year> >        yearAvl;

	ofstream outFile;
	ifstream inFile;
	tripNode tempTrip;
	List<tripNode> trip;
	Team        stad;
	string temp;
	tripNode       source;
	int size = 0;



    MainMenu(80);

	outFile.open("CONSOLE OUTPUT.txt");

	List<Team> stadiumList;

	GenerateStadiums("NFLStadiums.txt", stadiumList);

	stadiumList.to_front();
	ListNode<Team>* tempNode;

	while(!(stadiumList.isEmpty())){
		tempNode = stadiumList.pop();
		if(tempNode != NULL){
			Team tempStadium = tempNode->getData();
			stadiumAvl.insert(TeamContainer<stadiumName>(tempStadium));
			teamAvl.insert(TeamContainer<teamName>(tempStadium));
			yearAvl.insert(TeamContainer<year>(tempStadium));
		}
	}

	outFile << "------------------------------------------------------" << endl
			<< "-        LIST OF NFL TEAMS BY : STADIUM NAME          " << endl
			<< "------------------------------------------------------"
			<< endl << endl;
	outFile << stadiumAvl.inorder() << endl << endl;

	outFile << "------------------------------------------------------" << endl
			<< "-        LIST OF NFL TEAMS BY : TEAM NAME             " << endl
			<< "------------------------------------------------------"
			<< teamAvl.inorder() << endl << endl;

	outFile << "------------------------------------------------------" << endl
			<< "-        LIST OF NFL TEAMS BY : STADIUM NAME          " << endl
			<< "------------------------------------------------------"
			<< endl << endl;
	outFile << yearAvl.inorder() << endl << endl;




	outFile << "------------------------------------------------------" << endl
		    << "-     AVL TREE BY Team Name : ASCENDING ORDER     -" << endl
		    << "------------------------------------------------------"
		    << endl << endl;
	outFile << stadiumAvl.inorder();

	//START OF AVL TREE
		GenerateStadiums("NFLStadiums.txt", stadiumList);
		avltree< TeamContainer<roofType> > roofAvl;

		while(!(stadiumList.isEmpty())){
			tempNode = stadiumList.pop();
			if(tempNode != NULL){
				Team tempStadium = tempNode->getData();
				roofAvl.insert(TeamContainer<roofType>(tempStadium));
			}
		}

		outFile << "------------------------------------------------------" << endl
			    << "-     AVL TREE BY ROOF TYPE: ASCENDING ORDER     -" << endl
			    << "------------------------------------------------------"
			    << endl << endl;
		outFile << roofAvl.inorder();

	return 0;
}
Beispiel #10
0
 /*!
  * Start all jobs in \p list, i.e. add them to the \ref getWorkerPool
  */
 void Pipeline::startJobs(List<ThreadJob*>* list) {
     for (ListNode<ThreadJob*>* node = list->getFirstNode(); node; node = node->getNext()) {
         mWorkerPool->addJob(node->getData());
     }
     list->clear();
 }