int main(int argc,char ** argv){
	
	int * visitado,otimo;
	Tour pop[TAMPOP], * melhor;
	struct tms before,after;
	
	if(argc != 3){
		printf("USO : %s 'instancia' 'otimo' \n\n",argv[0]);
		return 1;
	}
	
	otimo = atoi(argv[2]);
	times(&before);
	
	read(argv[1],d,n);
	
	visitado = new_int(n);
	init_int(visitado,n);

	pop[0] = rand_tour();
	pop[1] = rand_tour();

	createSet();
	LinKernighan(pop[0]);	
	LinKernighan(pop[1]);

	pop[2] = new_tour(); pop[2]->c = new_int(n); pop[2]->pos = new_int(n);
	pop[3] = new_tour(); pop[3]->c = new_int(n); pop[3]->pos = new_int(n);

	PMX(pop[2],pop[3],pop[0],pop[1]);
	
	LinKernighan(pop[2]);	
	LinKernighan(pop[3]);
	
	printf("PAI 1 : \n");
	print_tour(pop[0]);
	printf("PAI 2 : \n");
	print_tour(pop[1]);	
	printf("FILHO 1 : \n");
	print_tour(pop[2]);	
	printf("FILHO 2 : \n");
	print_tour(pop[3]);
	
	melhor = &pop[0];
	//print_tour(melhor);
	times(&after);
	double tempo = (double)(after.tms_utime - before.tms_utime)/(double)100;
	double gap = ((double)((*(melhor))->cost-otimo)/(double) otimo) * 100.0;
	printf("%s\t%.2lfs\t%d\t%d\t%.3lf\n",argv[1],tempo,otimo,(*(melhor))->cost,gap);
    	//printf("System time: %ld seconds\n", after.tms_stime - before.tms_stime);
	
	return 0;

}
Exemple #2
0
treeNode *nameNode(int tok,treeNode *stagesNode,int nameId,int objId,treeNode *set) {

    nodeType type;
    switch(tok) {
    case OBJECT:
        type = objType;
        break;
    case DESOBJECT:
        type = desObjType;
        if(!nameId) nameId = inventName("DesObj");
        break;
    case REQUIRE:
        type = reqType;
        if(!nameId) nameId = inventName("Req");
        break;
    case OPTION:
        type = optType;
        if(!nameId) nameId = addSymbol("+NoNameOpt+");
        break;
    case START:
        type = startType;
        break;
    case END:
        type = endType;
        break;
    case SYMBOLS:
        type = symType;
        break;
    default:
        assert(NULL,"No Token");
    }
    startSetData *notParsed = set->data;

    nameData *name = Malloc(sizeof(nameData));
    name->nameId = nameId;
    name->objId = objId;
    name->elabNum = 0;
    name->set = createSet(notParsed);

    treeNode *newNode = Malloc(sizeof(treeNode));
    newNode->type = type;
    newNode->data = name;
    newNode->stages = NULL;

    if(stagesNode) {
        newNode->stages = stagesNode->data;
        Free(stagesNode);
    }

    destroyLinked(set->spaces,singleFree);
    Free(set);
    return newNode;
}
Exemple #3
0
treeNode *transNode(int type,treeNode *stagesNode,int transId,int objId,treeNode *startSet,treeNode *endSet){

	treeNode *newNode = Malloc(sizeof(treeNode));
	newNode->stages = NULL;
	transData *data = Malloc(sizeof(transData));
	
	if(stagesNode){
		newNode->stages = stagesNode->data;
		Free(stagesNode);
	}

	if(!transId)
		transId = inventName("Trans");

	data->transId = transId;
	data->objId = objId;
	
	startSetData *notParsedStart = startSet->data;
	startSetData *notParsedEnd = endSet->data;
	
	data->startData = createSet(notParsedStart);
	data->endData = createSet(notParsedEnd);
	
	// either Trans, TransSim, or TransLock
	if(type == TRANSFORM)
		newNode->type = transType;
	else if(type == TRANSFORMSIM)
		newNode->type = transSimType;
    else if(type == TRANSFORMLOCK)
		newNode->type = transLockType;

	newNode->data = data;

	destroyLinked(startSet->spaces,singleFree);
	destroyLinked(endSet->spaces,singleFree);

	Free(startSet);
	Free(endSet);
	return newNode;
}
Exemple #4
0
treeNode *storeNode(int tok,treeNode *set){

	nodeType type = boardType;
	switch(tok){
		case BOARD: 	break;
		default:		assert(NULL,"Node Error");
	}
	startSetData *notParsed = set->data;
	setData *newData = createSet(notParsed);

	set->type = type;
	set->data = newData;
	return set;
}
Exemple #5
0
int main(int argc, char *argv[])
{
    FILE *fp;
    char buffer[BUFSIZ];
    SET *odd;
    int words;


    /* Check usage and open the file. */

    if (argc != 2) {
        fprintf(stderr, "usage: %s file1\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    if ((fp = fopen(argv[1], "r")) == NULL) {
        fprintf(stderr, "%s: cannot open %s\n", argv[0], argv[1]);
        exit(EXIT_FAILURE);
    }


    /* Insert or delete words to compute their parity. */

words = 0;
    odd = createSet(MAX_SIZE);

    while (fscanf(fp, "%s", buffer) == 1) {
        words ++;

        if (hasElement(odd, buffer))
            removeElement(odd, buffer);
        else
            addElement(odd, buffer);
    }

    printf("%d total words\n", words);
    printf("%d words occur an odd number of times\n", numElements(odd));
    fclose(fp);

    destroySet(odd);
    exit(EXIT_SUCCESS);
}
Exemple #6
0
int main(int argc, char *argv[])
{
    FILE *fp;
    char buffer[MAX_WORD_LENGTH];
    SET *sets[MAX_WORD_LENGTH];
    int i;


    /* Check usage and open the file. */

    if (argc != 2) {
        fprintf(stderr, "usage: %s file1 [file2]\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    if ((fp = fopen(argv[1], "r")) == NULL) {
        fprintf(stderr, "%s: cannot open %s\n", argv[0], argv[1]);
        exit(EXIT_FAILURE);
    }


    /* Insert all words into the set of the appropriate length. */

    for (i = 0; i < MAX_WORD_LENGTH; i ++)
	sets[i] = createSet(MAX_UNIQUE);

    while (fscanf(fp, "%s", buffer) == 1)
        addElement(sets[strlen(buffer) - 1], buffer);

    fclose(fp);


    /* Display the counts for each word length. */

    for (i = 0; i < MAX_DISPLAYED; i ++) {
	printf("%5d distinct words ", numElements(sets[i]));
	printf("of length %d\n", i + 1);
    }

    exit(EXIT_SUCCESS);
}
Exemple #7
0
int main(int argc, char **argv) {
    uint8_t success;
    int i;
    intset *is;
    sranddev();

    printf("Value encodings: "); {
        assert(_intsetValueEncoding(-32768) == INTSET_ENC_INT16);
        assert(_intsetValueEncoding(+32767) == INTSET_ENC_INT16);
        assert(_intsetValueEncoding(-32769) == INTSET_ENC_INT32);
        assert(_intsetValueEncoding(+32768) == INTSET_ENC_INT32);
        assert(_intsetValueEncoding(-2147483648) == INTSET_ENC_INT32);
        assert(_intsetValueEncoding(+2147483647) == INTSET_ENC_INT32);
        assert(_intsetValueEncoding(-2147483649) == INTSET_ENC_INT64);
        assert(_intsetValueEncoding(+2147483648) == INTSET_ENC_INT64);
        assert(_intsetValueEncoding(-9223372036854775808ull) == INTSET_ENC_INT64);
        assert(_intsetValueEncoding(+9223372036854775807ull) == INTSET_ENC_INT64);
        ok();
    }

    printf("Basic adding: "); {
        is = intsetNew();
        is = intsetAdd(is,5,&success); assert(success);
        is = intsetAdd(is,6,&success); assert(success);
        is = intsetAdd(is,4,&success); assert(success);
        is = intsetAdd(is,4,&success); assert(!success);
        ok();
    }

    printf("Large number of random adds: "); {
        int inserts = 0;
        is = intsetNew();
        for (i = 0; i < 1024; i++) {
            is = intsetAdd(is,rand()%0x800,&success);
            if (success) inserts++;
        }
        assert(is->length == inserts);
        checkConsistency(is);
        ok();
    }

    printf("Upgrade from int16 to int32: "); {
        is = intsetNew();
        is = intsetAdd(is,32,NULL);
        assert(is->encoding == INTSET_ENC_INT16);
        is = intsetAdd(is,65535,NULL);
        assert(is->encoding == INTSET_ENC_INT32);
        assert(intsetFind(is,32));
        assert(intsetFind(is,65535));
        checkConsistency(is);

        is = intsetNew();
        is = intsetAdd(is,32,NULL);
        assert(is->encoding == INTSET_ENC_INT16);
        is = intsetAdd(is,-65535,NULL);
        assert(is->encoding == INTSET_ENC_INT32);
        assert(intsetFind(is,32));
        assert(intsetFind(is,-65535));
        checkConsistency(is);
        ok();
    }

    printf("Upgrade from int16 to int64: "); {
        is = intsetNew();
        is = intsetAdd(is,32,NULL);
        assert(is->encoding == INTSET_ENC_INT16);
        is = intsetAdd(is,4294967295,NULL);
        assert(is->encoding == INTSET_ENC_INT64);
        assert(intsetFind(is,32));
        assert(intsetFind(is,4294967295));
        checkConsistency(is);

        is = intsetNew();
        is = intsetAdd(is,32,NULL);
        assert(is->encoding == INTSET_ENC_INT16);
        is = intsetAdd(is,-4294967295,NULL);
        assert(is->encoding == INTSET_ENC_INT64);
        assert(intsetFind(is,32));
        assert(intsetFind(is,-4294967295));
        checkConsistency(is);
        ok();
    }

    printf("Upgrade from int32 to int64: "); {
        is = intsetNew();
        is = intsetAdd(is,65535,NULL);
        assert(is->encoding == INTSET_ENC_INT32);
        is = intsetAdd(is,4294967295,NULL);
        assert(is->encoding == INTSET_ENC_INT64);
        assert(intsetFind(is,65535));
        assert(intsetFind(is,4294967295));
        checkConsistency(is);

        is = intsetNew();
        is = intsetAdd(is,65535,NULL);
        assert(is->encoding == INTSET_ENC_INT32);
        is = intsetAdd(is,-4294967295,NULL);
        assert(is->encoding == INTSET_ENC_INT64);
        assert(intsetFind(is,65535));
        assert(intsetFind(is,-4294967295));
        checkConsistency(is);
        ok();
    }

    printf("Stress lookups: "); {
        long num = 100000, size = 10000;
        int i, bits = 20;
        long long start;
        is = createSet(bits,size);
        checkConsistency(is);

        start = usec();
        for (i = 0; i < num; i++) intsetSearch(is,rand() % ((1<<bits)-1),NULL);
        printf("%ld lookups, %ld element set, %lldusec\n",num,size,usec()-start);
    }

    printf("Stress add+delete: "); {
        int i, v1, v2;
        is = intsetNew();
        for (i = 0; i < 0xffff; i++) {
            v1 = rand() % 0xfff;
            is = intsetAdd(is,v1,NULL);
            assert(intsetFind(is,v1));

            v2 = rand() % 0xfff;
            is = intsetRemove(is,v2,NULL);
            assert(!intsetFind(is,v2));
        }
        checkConsistency(is);
        ok();
    }
}
void initLRU(long long cacheSize) {
    assert((lru = (LRU *)malloc(sizeof(LRU))) != NULL);
    lru->numPages = cacheSize;
    lru->pages = createSet(cacheSize);
    assert((fp = fopen("out.txt", "w")) != NULL);
}
StitchLibraryUi::StitchLibraryUi(QWidget* parent)
    : QDialog(parent), ui(new Ui::StitchLibraryDialog)
{
    ui->setupUi(this);

    ui->stitchSource->addItems(StitchLibrary::inst()->stitchSetList());

    StitchSet* master = StitchLibrary::inst()->masterStitchSet();

    mProxyModel = new QSortFilterProxyModel(this);

    mProxyModel->setSourceModel(master);
    mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);

    ui->listView->setModel(mProxyModel);
    ui->listView->setSortingEnabled(true);

    StitchLibraryDelegate *delegate = new StitchLibraryDelegate(ui->listView);
    ui->listView->setItemDelegate(delegate);

    setDialogSize();
    ui->listView->horizontalHeader()->setClickable(true);
    ui->listView->horizontalHeader()->setSortIndicatorShown(true);

    //TODO: Wrong Side.
    ui->listView->hideColumn(4);

    ui->propertiesBox->setVisible(false);
    connect(ui->moreBttn, SIGNAL(clicked()), SLOT(hideProperties()));
    connect(ui->printSet, SIGNAL(clicked()), SLOT(printStitchSet()));

    connect(ui->addStitch, SIGNAL(clicked()), SLOT(addStitch()));
    connect(ui->removeStitch, SIGNAL(clicked()), SLOT(removeStitch()));
    connect(ui->addSelected, SIGNAL(clicked()), SLOT(addSelected()));

    connect(ui->createSet, SIGNAL(clicked()), SLOT(createSet()));
    connect(ui->removeSet, SIGNAL(clicked()), SLOT(removeSet()));

    connect(ui->importSet, SIGNAL(clicked()), SLOT(importSet()));
    connect(ui->exportSet, SIGNAL(clicked()), SLOT(exportSet()));

    connect(ui->setName, SIGNAL(editingFinished()), SLOT(updateStitchSetProperties()));
    connect(ui->author,  SIGNAL(editingFinished()), SLOT(updateStitchSetProperties()));
    connect(ui->email,   SIGNAL(editingFinished()), SLOT(updateStitchSetProperties()));
    connect(ui->org,     SIGNAL(editingFinished()), SLOT(updateStitchSetProperties()));
    connect(ui->url,     SIGNAL(editingFinished()), SLOT(updateStitchSetProperties()));

    setupPropertiesBox();
    
    connect(ui->stitchSource, SIGNAL(currentIndexChanged(QString)), SLOT(changeStitchSet(QString)));

    connect(ui->resetLibrary, SIGNAL(clicked()), SLOT(resetLibrary()));
    connect(ui->icons, SIGNAL(clicked()), SLOT(iconDialog()));

    connect(ui->listView->horizontalHeader(),
            SIGNAL(sectionClicked(int)), SLOT(updateRowSizes()));

    connect(ui->stitchFilter, SIGNAL(textChanged(QString)), SLOT(filterStitchList(QString)));
    connect(ui->clearBttn, SIGNAL(clicked()), SLOT(clearStitchFilter()));

    setButtonStates(master);
}
Exemple #10
0
int main (int argc, char *argv [])
{
    SET *set;
    FILE *fp;
    char buffer [BUFSIZ];
    int words;


    /* Check usage and open the first file. */

    if (argc == 1 || argc > 3) {
	fprintf (stderr, "usage: %s file1 [file2]\n", argv [0]);
	exit (EXIT_FAILURE);
    }

    if ((fp = fopen (argv [1], "r")) == NULL) {
	fprintf (stderr, "%s: cannot open %s\n", argv [0], argv [1]);
	exit (EXIT_FAILURE);
    }


    /* Insert all words into the set. */

    words = 0;

    if ((set = createSet (MAX_SIZE)) == NULL) {
	fprintf (stderr, "%s: failed to create set\n", argv [0]);
	exit (EXIT_FAILURE);
    }

    while (fscanf (fp, "%s", buffer) == 1) {
	words ++;

	if (!hasElement (set, buffer))
	    if (!insertElement (set, strdup (buffer)))
		fprintf (stderr, "set full\n");
    }

    printf ("%d total words\n", words);
    printf ("%d unique words\n", numElements (set));
    fclose (fp);


    /* Try to open the second file. */

    if (argc == 3) {
	if ((fp = fopen (argv [2], "r")) == NULL) {
	    fprintf (stderr, "%s: cannot open %s\n", argv [0], argv [1]);
	    exit (EXIT_FAILURE);
	}


	/* Delete all words in the second file. */

	while (fscanf (fp, "%s", buffer) == 1)
	    deleteElement (set, buffer);

	printf ("%d remaining words\n", numElements (set));
    }

    destroySet (set);
    exit (EXIT_SUCCESS);
}
Exemple #11
0
int
main(int argc, char* argv[])
{
    bool add = false, create = false, destroy = false, erase = false, header = false;
    bool list = false, lvcreate = false, lvdestroy = false, lvlist = false, lvmodify = false, lvresize = false, lvsnap = false;
    bool modify = false, remove = false, spare = false, watch = false;
    char * setLevel = 0, * setName = 0; 

    /* options descriptor */
    static struct option longopts[] = {
	{ "add",	required_argument,	0,	'a' },
	{ "create",	no_argument,		0,	'c' },
	{ "destroy",	required_argument,	0,	'd' },
	{ "erase",	no_argument,		0,	'e' },
	{ "header",	no_argument,		0,	'h' },
	{ "list",	no_argument,		0,	'l' },
	{ "modify",	required_argument,	0,	'm' },
	{ "remove",	required_argument,	0,	'r' },
	{ "spare",	required_argument,	0,	's' },
	{ "watch",	no_argument,		0,	'w' },
	
	{ "lvcreate",	required_argument,	0,	'C' },
	{ "lvdestroy",	required_argument,	0,	'D' },
	{ "lvlist",	no_argument,		0,	'L' },
	{ "lvmodify",	required_argument,	0,	'M' },
	{ "lvresize",	required_argument,	0,	'R' },
	{ "lvsnap",	required_argument,	0,	'S' },
	
	{ "auto-rebuild",required_argument,	0,	'A' },
	{ "block-size", required_argument,	0,	'B' },
	{ "extents",	no_argument,		0,	'E' },
	{ "hint",	required_argument,	0,	'H' },
	{ "level",	required_argument,	0,	'V' },
	{ "name",	required_argument,	0,	'N' },
	{ "quick-rebuild",required_argument,	0,	'Q' },
	{ "size",	required_argument,	0,	'Z' },
	{ "timeout",	required_argument,	0,	'T' },

	{ "verbose",	no_argument,		0,	'v' },
	{ "help",	no_argument,		0,	'?' },
	{ 0,		0,			0,	0   }
    };

    int ch;
    while ((ch = getopt_long(argc, argv, "a:cd:ehlm:r:s:wC:D:LM:R:S:A:B:EH:V:N:Q:Z:T:v?", longopts, NULL)) != -1) {
	
	switch(ch) {

	case 'a':
	    add = true;
	    setName = strdup(optarg);
	    break;
	case 'c':
	    create = true;
	    break;
	case 'd':
	    destroy = true;
	    setName = strdup(optarg);
	    break;
	case 'e':
	    erase = true;
	    break;
	case 'h':
	    header = true;
	    break;
	case 'l':
	    list = true;
	    break;
	case 'm':
	    modify = true;
	    setName = strdup(optarg);
	    break;
	case 'r':
	    remove = true;
	    setName = strdup(optarg);
	    break;
	case 's':
	    spare = true;
	    setName = strdup(optarg);
	    break;
	case 'w':
	    watch = true;
	    break;

	    
	case 'C':
	    lvcreate = true;
	    setName = strdup(optarg);
	    break;
	case 'D':
	    lvdestroy = true;
	    setName = strdup(optarg);
	    break;
	case 'L':
	    lvlist = true;
	    break;
	case 'M':
	    lvmodify = true;
	    setName = strdup(optarg);
	    break;
	case 'R':
	    lvresize = true;
	    setName = strdup(optarg);
	    break;
	case 'S':
	    lvsnap = true;
	    setName = strdup(optarg);
	    break;


	case 'A':
	    autoRebuild = ((optarg[0] == 'Y') || (optarg[0] == 'y')) ? AUTO_YES : AUTO_NO;
	    break;
	case 'B':
	    sscanf(optarg, "%lli", &blockSize);
	    break;
	case 'E':
	    extents = true;
	    break;
	case 'H':
	    hint = strdup(optarg);
	    break;
	case 'V':
	    setLevel = strdup(optarg);
	    break;
	case 'N':
	    nickname = strdup(optarg);
	    break;
	case 'Q':
	    quickRebuild = ((optarg[0] == 'Y') || (optarg[0] == 'y')) ? AUTO_YES : AUTO_NO;
	    break;
	case 'Z':
	    sscanf(optarg, "%lli", &volSize);
	    break;
	case 'T':
	    sscanf(optarg, "%lli", &timeout);
	    break;


	case 'v':
	    verbose = true;
	    break;
	case 0:
	case '?':
	default:
	    usage();
	    exit(0);
	}
    }
    argc -= optind;
    argv += optind;

    if (!add && !create && !destroy && !erase && !header && !list && !modify && !remove && !spare && !watch &&
	!lvcreate && !lvdestroy && !lvlist && !lvmodify && !lvresize && !lvsnap) {
	usage();
	exit(0);
    }

    if (list) {
	listRAIDSets();
	exit(0);
    }

    if (lvlist) {
	listLogicalVolumes(NULL, argc, argv);
	exit(0);
    }

    if (geteuid()) {
	printf("ERROR: you must be super user for this operation.\n");
	exit(1);
    }
	
    if (erase) {
	erasePartition(argc, argv);
	exit(0);
    };

    if (header) {
	dumpHeader(argc, argv);
	exit(0);
    };

    if (watch) {

	CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(),
					NULL,					// const void *observer
					callBack,
					CFSTR(kAppleRAIDNotificationSetDiscovered),
					NULL,					// const void *object
					CFNotificationSuspensionBehaviorHold);

	CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(),
					NULL,					// const void *observer
					callBack,
					CFSTR(kAppleRAIDNotificationSetTerminated),
					NULL,					// const void *object
					CFNotificationSuspensionBehaviorHold);

	CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(),
					NULL,					// const void *observer
					callBack,
					CFSTR(kAppleRAIDNotificationSetChanged),
					NULL,					// const void *object
					CFNotificationSuspensionBehaviorHold);

	CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(),
					NULL,					// const void *observer
					callBack,
					CFSTR(kAppleLVMNotificationVolumeDiscovered),
					NULL,					// const void *object
					CFNotificationSuspensionBehaviorHold);

	CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(),
					NULL,					// const void *observer
					callBack,
					CFSTR(kAppleLVMNotificationVolumeTerminated),
					NULL,					// const void *object
					CFNotificationSuspensionBehaviorHold);

	CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(),
					NULL,					// const void *observer
					callBack,
					CFSTR(kAppleLVMNotificationVolumeChanged),
					NULL,					// const void *object
					CFNotificationSuspensionBehaviorHold);

	// this will not fail if there is no raid controller, ie, if AppleRAID class is not instantiated in the kernel

	AppleRAIDEnableNotifications();
    }


    if (add) addMember(setName, CFSTR(kAppleRAIDMembersKey), argc, argv);
    if (create) createSet(setLevel, nickname, argc, argv);
    if (destroy) destroySet(setName, argc, argv);
    if (modify) modifySet(setName, argc, argv);
    if (remove) removeMember(setName, argc, argv);
    if (spare) addMember(setName, CFSTR(kAppleRAIDSparesKey), argc, argv);

    
    if (lvcreate) createLogicalVolume(setName, setLevel, argc, argv);
    if (lvdestroy) destroyLogicalVolume(setName, argc, argv);
    if (lvmodify) modifyLogicalVolume(setName, argc, argv);
    if (lvresize) resizeLogicalVolume(setName, argc, argv);
    if (lvsnap) snapshotLogicalVolume(setName, setLevel, argc, argv);

    
    if (watch) {

	printf("watching...\n");

	// Set up a signal handler so we can clean up when we're interrupted from the command line
	// Otherwise we stay in our run loop forever.
	sig_t oldHandler = signal(SIGINT, signalHandler);
	if (oldHandler == SIG_ERR) {
	    printf("Could not establish new signal handler");
	    exit(1);
	}

	// Start the run loop. Now we'll receive notifications.
	//
	printf("Starting run loop.\n");
	CFRunLoopRun();
        
	printf("Unexpectedly back from CFRunLoopRun()!\n");
    }

    return 0;
}
Exemple #12
0
int main() {
	reset();
	createSet();
	readSet();
	return 0;
}
Exemple #13
0
Box* JitFragmentWriter::createSetHelper(uint64_t num, Box** data) {
    BoxedSet* set = (BoxedSet*)createSet();
    for (int i = 0; i < num; ++i)
        set->s.insert(data[i]);
    return set;
}
void WriteCPlusPlusClass::writeInclude(QFile &file, JsonClass newClass)
{
    //QFile file("/tmp/test.h");

    file.write("#include\"../../JsonClassInterface.h\"");
    file.write("\n");

    for (int i = 0; i < newClass.fields.size(); i++) {
        if (!defaultType.contains(newClass.fields.at(i).type)) {
            if (newClass.fields.at(i).type == "string") {
                file.write(QString("#include<QString>\n").toStdString().c_str());
                // write QString
            } else {
                // write name type
            }
        }
    }
    file.write("\n");
    file.write(QString("class " + newClass.name +":public JsonClassInterface {\n").toStdString().c_str());
    file.write("private:\n");
    for (int i = 0; i < newClass.fields.size(); i++) {
        if (newClass.fields.at(i).type == "integer") {
           file.write(QString("\tint " + newClass.fields.at(i).name + ";\n").toStdString().c_str());
        }
        else if (newClass.fields.at(i).type == "string") {
            file.write(QString("\tQString " + newClass.fields.at(i).name + ";\n").toStdString().c_str());
            // write QString
        } else {
            file.write(QString("\t" + newClass.fields.at(i).type + " " + newClass.fields.at(i).name + ";\n").toStdString().c_str());
        }

    }

    // write methods

    file.write("\npublic:\n");

    file.write(QString(QString("\t") + newClass.name +"();\n").toStdString().c_str());

    for (int i = 0; i < newClass.fields.size(); i++) {


        if (newClass.fields.at(i).type == "integer") {

           file.write(QString("\tint " + createGet(newClass.fields.at(i)) + ";\n").toStdString().c_str());
        }
        else if (newClass.fields.at(i).type == "string") {
            file.write(QString("\tQString " + createGet(newClass.fields.at(i)) + ";\n").toStdString().c_str());
            // write QString
        } else {
            file.write(QString("\t" + newClass.fields.at(i).type + " " + createGet(newClass.fields.at(i)) + ";\n").toStdString().c_str());
        }

    }

    for (int i = 0; i < newClass.fields.size(); i++) {


        if (newClass.fields.at(i).type == "integer") {

           file.write(QString("\t" + createSet(newClass.fields.at(i), "int") + ";\n").toStdString().c_str());
        }
        else if (newClass.fields.at(i).type == "string") {
            file.write(QString("\t" + createSet(newClass.fields.at(i), "QString") + ";\n").toStdString().c_str());
            // write QString
        } else {
            file.write(QString("\t" + createSet(newClass.fields.at(i), newClass.fields.at(i).type) + ";\n").toStdString().c_str());
        }

    }

    file.write(QString("\tvoid read(const QJsonObject &json);\n").toStdString().c_str());
    file.write(QString("\tvoid write(QJsonObject &json) const;\n").toStdString().c_str());
    file.write("};\n");
}