Ejemplo n.º 1
0
void PastWeightMatrix::increaseSize()
{
    //Expand arrays.
    expandArray(previousOutputs, m_numRounds * 2);
    expandArray(idealOutputs, m_numRounds * 2);

    m_numRounds *= 2;
}
Ejemplo n.º 2
0
//checks if dynamic array needs to be expanded and then finds where the new event 
//should be inserted into the array and calls shiftarray() to put it there
void Day::scheduleEvent(int startTime, int endTime, string description){
	  if (eventCount >= eventCapacity){
	    expandArray();
	  }
	  if(eventCount == 0){      //checks if array is empty
	    shiftArray(0, startTime, endTime, description);
	  }
	  if(startTime < eventList[0].getStartTime()){ //checks if event goes before 1st
	    shiftArray(0, startTime, endTime, description); //event in the array
	  }
	  for(int i = 1; i < eventCount; i++){ //checks if event goes in the middle of array
	    if((startTime > eventList[i - 1].getStartTime()) && 
	      (startTime < eventList[i].getStartTime())){
		shiftArray(i, startTime, endTime, description);
		break;
	    }
	    if(startTime == eventList[i].getStartTime()){  //checks to see if event is the same 
		shiftArray(i + 1, startTime, endTime, description); //as another event
		break;
	    }
	  }
	  if(startTime > eventList[eventCount - 1].getStartTime()){ //checks if event goes at end of array
	    shiftArray(eventCount, startTime, endTime, description);
	  }
}
Ejemplo n.º 3
0
int main() {

	base = (char**) malloc(sizeof(char*));
	const char *symbolsEnd = symbolsPtr+strlen(symbols);

	// while length of base is smaller or equal to given string length
	while(currentLength <= MAX_LENGTH) {
		while(symbolsPtr < symbolsEnd) {
			base[currentLength-1] = symbolsPtr++;
			printArray(base,currentLength); // Combinations!
		}

		for(i=currentLength-1,counter=0;i>=0;i--) {
			if(*base[i] == *(symbolsEnd-1)) {
				counter++;
			}
			else break;
		}
		// if all positions have the highest character expand array for 1 because of the overflow 			
		if(counter == currentLength) {
			expandArray(base,symbols,currentLength);
			currentLength++;
		}
		// else "carry 1"
		else {
			base[currentLength-counter-1]++;
			for(i=currentLength-1;i>=currentLength-counter;i--) {
				base[i] = symbols;
			}
		}
		symbolsPtr = symbols;
	}
	free(base);
	return 0;
}
Ejemplo n.º 4
0
void JSON::setArrayArray(int index, JSON *value)
{
    if (!isArray() || !value || !value->_json || !json_is_array(value->_json))
    {
        return;
    }

    expandArray(index + 1);

    json_array_set(_json, index, value->_json);
}
Ejemplo n.º 5
0
void JSON::setArrayString(int index, const char *value)
{
    if (!isArray())
    {
        return;
    }

    expandArray(index + 1);

    json_array_set(_json, index, json_string(value));
}
Ejemplo n.º 6
0
void JSON::setArrayNumber(int index, double value)
{
    if (!isArray())
    {
        return;
    }

    expandArray(index + 1);

    json_array_set(_json, index, json_real(value));
}
Ejemplo n.º 7
0
void JSON::setArrayFloat(int index, float value)
{
    if (!isArray())
    {
        return;
    }

    expandArray(index + 1);

    json_array_set(_json, index, json_real(value));
}
Ejemplo n.º 8
0
void JSON::setArrayInteger(int index, int value)
{
    if (!isArray())
    {
        return;
    }

    expandArray(index + 1);

    json_array_set(_json, index, json_integer(value));
}
Ejemplo n.º 9
0
void JSON::setArrayBoolean(int index, bool value)
{
    if (!isArray())
    {
        return;
    }

    expandArray(index + 1);

    json_array_set(_json, index, value ? json_true() : json_false());
}