Exemple #1
0
	void ReverseArrayIterator::reset()
	{
		for (size_t i = 0, n = outPos.size(); i < n; i++) {
            outPos[i] = array.dims[i].getStartMin();
        }
        outPos[outPos.size()-1] -= array.dims[outPos.size()-1].getChunkInterval();
        hasCurrent = nextAvailable();
        chunkInitialized = false;
    }
Exemple #2
0
// a menu to switch through some options...
void menu(int opcao, contato reg, char *buffer, FILE *arq)
{
    int sizeReg, nextPositionAvailable, remover, i;
    switch (opcao) {
    case 1: //insercao
    {
        printf("\ninsercao");

        reg = readContact();  // read from the user input

        sizeReg = concatenateReg(reg, buffer, arq);  //mount the register in order to be stored
        printf("\nDebug: Registro a ser escrito: %s", buffer);
        printf("\nDebug: Tamanho do Registro a ser escrito: %d \n", sizeReg);
        insertIntoIndexMap(sizeReg);
        printIndexMap();
        nextPositionAvailable = nextAvailable(arq, sizeReg);

        getchar();
        break;
    }
    case 2: //remocao
    {
        printf("\n -----====== REMOCAO de Registro =====----- ");
        createIndexMap(arq);
        printIndexMap();
        printf("\nDigite o Codigo do registro a ser removido:");
        fpurge(stdin);   // fflush(stdin)  // no windows
        scanf("%d", &remover);
        i = 1;
        while (indexMap[i][2] != remover && indexMap[i][0] != -1 )  //code not found AND not EOF
        {
            printf("indexMap[%d][2] = %d - ", i, indexMap[i][2]);
            i++;
        }
        if (indexMap[i][2] == remover )
        {
            indexMap[i][1] = 42; // set * to the desired register
            fseek(arq,indexMap[i][3],0);  //position the cursor at the register to be removed
            fseek(arq, 4, 1);   // move 4 bytes to move to the validation char (@ or *)
            fwrite("*" , 1 , sizeof(char) , arq );  // writes * to remove logically the register
            printf("\nRegistro apagado");
            printIndexMap();
        }
        if ( indexMap[i][0] == -1 ) // if reachs the EOF, so the register wasn't founded
        {
            printf("Registro nao encontrado!");
        }
        fpurge(stdin);   // fflush(stdin)  // no windows
        getchar();
        break;
    }
    case 3: //compactacao
    {
        printf("\ncompactacao");
        getchar();
        break;
    }
    case 4: // Debug Renew indexMap
    {
        //createIndexMap(arq);
        printIndexMap();
        fpurge(stdin);   // fflush(stdin)  // no windows
        getchar();
        break;
    }
    case 0: // exit
    {
        printf("\nSaindo do programa!");
        getchar();
        break;
    }
    default:  // invalid choices
    {
        printf("\nEscolha invalida!");
        getchar();
        break;
    }
    }
}
Exemple #3
0
	void ReverseArrayIterator::operator ++()
	{
        if (!hasCurrent)
            throw USER_EXCEPTION(SCIDB_SE_EXECUTION, SCIDB_LE_NO_CURRENT_ELEMENT);
        hasCurrent = nextAvailable();
    }