Beispiel #1
0
int main()
{
    char buffer[80];
    int i, index;
    Set set1, set2, set3;

    i = 0;  
    while ( (scanf("%s",buffer)) != EOF )
    {
        strcpy(names[i],buffer);
        i++;
    }
    printf("The initial data is:\n");
    print(names,i);
    bubbleSort(names,i);
    printf("\n\nThe sorted data is:\n");
    print(names,i);

    clearSet(set1);
    clearSet(set2);
    clearSet(set3);

    printf("Adding Warner, Faulk and Pace to set1:\n");
    addName2Set(set1,"Warner");
    addName2Set(set1,"Faulk");
    addName2Set(set1,"Pace");
    printf("Set1 = ");
    printSet(set1);

    printf("Adding Snider, Robinson and Koufax to set2:\n");
    addName2Set(set2,"Snider");
    addName2Set(set2,"Robinson");
    addName2Set(set2,"Koufax");
    printf("Set2 = ");
    printSet(set2);

    setUnion(set1, set2, set3);
    printf("The union of sets 1 and 2 is: ");
    printSet(set3);
    
    printf("The intersection of sets 3 and 2 is: ");
    setIntersection(set3, set2, set3);
    printSet(set3);

    printf("Deleting Snider from set3:\n");
    deleteNameFromSet(set3,"Snider");    
    printf("Set3 = ");
    printSet(set3);
}
	void refreshChildren(
		bool refreshImmediate,
		bool clearEverything = false,
		bool refreshUnderground = false
	) {
		int i;
		
		
		
		
		
		
		readyForClear = true;
		if (clearEverything) {
			clearSet();
		}
		
		for (i = 0; i < iPageDataVolume; i++) {
			if (pageData[i] == NULL) {

			}
			else {
				
				
				if (refreshImmediate) {
					if (
						(
							(pageData[i]->hasSolids || pageData[i]->hasTrans)
						) ||
						refreshUnderground
					) {
						if (refreshUnderground) {
							pageData[i]->isDirty = true;
						}
						pageData[i]->generateVolume(refreshUnderground);
					}
					childrenDirty = false;
				}
				else {
					childrenDirty = true;
					pageData[i]->isDirty = true;
				}
				
				
				
			}
		}
		

		
	}
Beispiel #3
0
void AbstractOptionStorage::startSet()
{
    GMX_RELEASE_ASSERT(!bInSet_, "finishSet() not called");
    // The last condition takes care of the situation where multiple
    // sources are used, and a later source should be able to reassign
    // the value even though the option is already set.
    if (isSet() && !hasFlag(efOption_MultipleTimes)
        && !hasFlag(efOption_ClearOnNextSet))
    {
        GMX_THROW(InvalidInputError("Option specified multiple times"));
    }
    clearSet();
    bInSet_              = true;
    bSetValuesHadErrors_ = false;
}
Beispiel #4
0
void AbstractOptionStorage::finishSet()
{
    GMX_RELEASE_ASSERT(bInSet_, "startSet() not called");
    bInSet_ = false;
    // We mark the option as set even when there are errors to avoid additional
    // errors from required options not set.
    // TODO: There could be a separate flag for this purpose.
    setFlag(efOption_Set);
    if (!bSetValuesHadErrors_)
    {
        // TODO: Correct handling of the efOption_ClearOnNextSet requires
        // processSet() and/or convertValue() to check it internally.
        // OptionStorageTemplate takes care of it, but it's error-prone if
        // a custom option is implemented that doesn't use it.
        processSet();
    }
    bSetValuesHadErrors_ = false;
    clearFlag(efOption_ClearOnNextSet);
    clearSet();
}
Beispiel #5
0
int main() {
	int i, num, cNum;
	char temp1[257], temp2[257], classString[12], buffer[80], call[80], test[80], next[80];
	stack s;
	Set dset;
	initStack(&s);

	DBRecord **students;

	scanf("%d", &num);
	printf("%d \n", num);

    students = (DBRecord **) malloc(num * sizeof(DBRecord *));

	for(i = 0; i < num; i++) {
		students[i] = (DBRecord *) malloc (sizeof(DBRecord));
		students[i]->bitID = i;
		scanf("%s %s %s %d %s %f %d", temp1, temp2, students[i]->idNum, &students[i]->age, classString, &students[i]->gpa, &students[i]->expectedGrad);

		//  allocate space for character strings, and copy the strings */
		students[i]->lName = (char *) malloc(strlen(temp1) + 1);
		strcpy(students[i]->lName, temp1);
		students[i]->fName = (char *) malloc(strlen(temp2) + 1);
		strcpy(students[i]->fName, temp2);

		// set the year field from the strings of Class values
		if( (strcmp(classString,"firstYear")) == 0 )
			students[i]->year = firstYear;

		else if( (strcmp(classString,"sophmore")) == 0 )
			students[i]->year = sophomore;

		else if( (strcmp(classString,"junior")) == 0 )
			students[i]->year = junior;

		else if( (strcmp(classString,"senior")) == 0 )
			students[i]->year = senior;

		else if( (strcmp(classString,"grad")) == 0 )
			students[i]->year = grad;

		else
			assert(0);

	}
	printf("Done scanning \n");

	while (scanf("%s", buffer) != EOF) {
		if (strcmp(buffer, "create") == 0) {
			clearSet(dset);
			scanf("%s", call);
			scanf("%s", test);

			if (strcmp(call, "lastName") == 0) {
				scanf("%s", next);
				if (strcmp(test, "=") == 0) {
					for(i = 0; i < num; i++) {
						if (strcmp(students[i]->lName, next) == 0)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, "<") == 0) {
					for(i = 0; i < num; i++) {
						if (strcmp(students[i]->lName, next) < 0)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, ">") == 0) {
					for(i = 0; i < num; i++) {
						if (strcmp(students[i]->lName, next) > 0)
							add2Set(dset, students[i]->bitID);
					}
				}
			}
			if (strcmp(call, "firstName") == 0) {
				scanf("%s", next);
				if (strcmp(test, "=") == 0) {
					for(i = 0; i < num; i++) {
						if (strcmp(students[i]->fName, next) == 0)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, "<") == 0) {
					for(i = 0; i < num; i++) {
						if (strcmp(students[i]->fName, next) < 0)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, ">") == 0) {
					for(i = 0; i < num; i++) {
						if (strcmp(students[i]->fName, next) > 0)
							add2Set(dset, students[i]->bitID);
					}
				}
			}
			if (strcmp(call, "idNum") == 0) {
				scanf("%s", next);
				if (strcmp(test, "=") == 0) {
					for(i = 0; i < num; i++) {
						if (strcmp(students[i]->idNum, next) == 0)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, "<") == 0) {
					for(i = 0; i < num; i++) {
						if (strcmp(students[i]->idNum, next) < 0)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, ">") == 0) {
					for(i = 0; i < num; i++) {
						if (strcmp(students[i]->idNum, next) > 0)
							add2Set(dset, students[i]->bitID);
					}
				}
			}
			if (strcmp(call, "age") == 0) {
				scanf("%d", &cNum);
				if (strcmp(test, "=") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->age == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, "<") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->age == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, ">") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->age == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
			}
			if (strcmp(call, "year") == 0) {
				scanf("%d", &cNum);
				if (strcmp(test, "=") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->year == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, "<") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->year == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, ">") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->year == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
			}
			if (strcmp(call, "gpa") == 0) {
				scanf("%d", &cNum);
				if (strcmp(test, "=") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->gpa == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, "<") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->gpa == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, ">") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->gpa == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
			}
			if (strcmp(call, "expectedGrad") == 0) {
				scanf("%d", &cNum);
				if (strcmp(test, "=") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->expectedGrad == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, "<") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->expectedGrad == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
				if (strcmp(test, ">") == 0) {
					for(i = 0; i < num; i++) {
						if(students[i]->expectedGrad == cNum)
							add2Set(dset, students[i]->bitID);
					}
				}
			}
			push(&s, dset);
			printf("Created & Pushed Set \n");
		}
		if (strcmp(buffer, "union")) {
			Set uset1, uset2, urset;
			memcpy(uset2, pop(&s), 10 * sizeof(unsigned int));
			memcpy(uset1, pop(&s), 10 * sizeof(unsigned int));
			setUnion(uset1, uset2, urset);
			push(&s, urset);
			printf("Pushed Set \n");
		}
		if (strcmp(buffer, "intersection")) {
			Set iset1, iset2, irset;
			memcpy(iset2, pop(&s), 10 * sizeof(unsigned int));
			memcpy(iset1, pop(&s), 10 * sizeof(unsigned int));
			setIntersection(iset1, iset2, irset);
			push(&s, irset);
			printf("Pushed Set \n");
		}
		if (strcmp(buffer, "print")) {
			Set pset;
			memcpy(pset, pop(&s), 10 * sizeof(unsigned int));
			printSet(pset);
		}
		
	}
}