Пример #1
0
int main (void) {
    int** layer1 = makeArray();
    int** layer2 = makeArray();
    int** temp;
    srand(time(NULL));

    populate (layer1);

    prettyPrint (layer1);

    while (1) {

        struct timeval bad;
        bad.tv_sec = 0;
        bad.tv_usec = 10000;
        select (0, NULL, NULL, NULL, &bad);
        iterate (layer1, layer2);

        prettyPrint (layer2);

        temp = layer1;
        layer1 = layer2;
        layer2 = temp;
        
    }
    return 0;
}
Пример #2
0
void drawString(drawing* d, char* s, int boardX, int boardY){
	int length = strlen(s);
	char c;

	d->canvas = makeArray(CHRCX,(CHRCY+1)*length);

	d->x = boardX;
	d->y = boardY;

	d->width = (CHRCX+1)*length;
	d->height = CHRCY;
	for(int i=0; i<length; i++){
		c = s[i];

		if(c>='0' && c<='9'){
			drawChrc_numb(d, c-48, i*(CHRCX+1));
		}
		else if(c>='A' && c<='Z'){
			drawChrc_ucas(d, c-65, i*(CHRCX+1));
		}
		else if(c>='a' && c<='z'){
			drawChrc_lcas(d, c-97, i*(CHRCX+1));
		}
		else if(c==' '){
			drawChrc_spce(d, i*(CHRCX+1));
		}
	}
}
Пример #3
0
int add(char *username, char *password, char *type) 
{
    
    makeArray();

    for(i = 0; i < numberOfLines; i++) 
    {
        char tempName[50];
        strcpy(tempName, username);
        strcat(tempName, ",");
        if(strncmp(array[i], tempName, strlen(tempName)) == 0) return EXIT_FAILURE;
    }

    strcpy(array[numberOfLines], username); //we add username to the array
    strcat(array[numberOfLines], ", "); //we remove the ',' between each string
    strcat(array[numberOfLines], password);
    strcat(array[numberOfLines], ", ");
    strcat(array[numberOfLines], type);
    
    encrypt(array);
    out=fopen("password.csv", "wt");
    for (i=0; i<numberOfLines; i++) 
    {
        fprintf(out, "%s\n", array[i]);
    }
    fclose(out);
    return EXIT_SUCCESS;
}
Пример #4
0
/*
Shifts the content of the rectangle into a parallelogram

@param: drawing* d
*/
void shearHrz(drawing* d, int factor){
	

	bool** temp = makeArray(d->width + abs(factor)*(d->height-1), d->height);

	if (factor > 0){
		for(int i = 0; i < d->height; i++){
			for(int j = 0; j < d->width; j++){
				temp[i][j+((d->height-i-1)*factor)] = d->canvas[i][j];
			}
		}
	}
	else{
		factor *= -1;
		for(int i = 0; i < d->height; i++){
			for(int j = 0; j < d->width; j++){
				temp[i][j+(i*factor)] = d->canvas[i][j];
			}
		}
	}
	bool** clone = d->canvas;
	d->canvas = temp;
	free(clone);

	d->width += factor*(d->height-1);
}
Пример #5
0
int main() {

  std::vector<PID::Produce> product_list = makeArray();
  sf::Text text;
  text.setString(
      "Bar Code: " + product_list[0].getBarcode() + "\n" + "Name: " +
      product_list[0].getName() + "\n" + "Store Date: " +
      std::to_string(product_list.at(0).getStoredDate().getMonth()) + "/" +
      std::to_string(product_list.at(0).getStoredDate().getDay()) + "/" +
      std::to_string(product_list.at(0).getStoredDate().getYear() + 1900) +
      "\n");
  sf::Font font;
  font.loadFromFile("RobotoCondensed-Light.ttf");
  text.setFont(font);
  text.setPosition(680, 100);

  sf::Texture texture;
  texture.loadFromFile("resources/1.jpg");
  sf::Sprite sprite;
  sprite.setTexture(texture);
  sf::RenderWindow window(sf::VideoMode(1280, 720), "FridgeFriend");
  while (window.isOpen()) {
    sf::Event event;
    while (window.pollEvent(event)) {
      if (event.type == sf::Event::Closed)
        window.close();
    }
    window.clear();
    window.draw(sprite);
    window.draw(text);
    window.display();
  }

  return 0;
}
Пример #6
0
Array::operator const Poco::Dynamic::Array& () const
{
	if (!_pArray)
	{
		ValueVec::const_iterator it = _values.begin();
		ValueVec::const_iterator end = _values.end();
		_pArray = new Poco::Dynamic::Array;
		int index = 0;
		for (; it != end; ++it, ++index)
		{
			if (isObject(it))
			{
				_pArray->insert(_pArray->end(), Poco::JSON::Object::makeStruct(getObject(index)));
			}
			else if (isArray(it))
			{
				_pArray->insert(_pArray->end(), makeArray(getArray(index)));
			}
			else
			{
				_pArray->insert(_pArray->end(), *it);
			}
		}
	}

	return *_pArray;
}
Пример #7
0
void IniSetting::ParserCallback::onPopEntry(
    const std::string &key,
    const std::string &value,
    const std::string &offset,
    void *arg) {
  Variant *arr = (Variant*)arg;
  forceToArray(*arr);

  bool oEmpty = offset.empty();
  // Substitution copy or symlink
  // Offset come in like: hhvm.a.b\0c\0@
  // Check for `\0` because it is possible, although unlikely, to have
  // something like hhvm.a.b[c@]. Thus we wouldn't want to make a substitution.
  if (!oEmpty && (offset.size() == 1 || offset[offset.size() - 2] == '\0') &&
      (offset.back() == '@' || offset.back() == ':')) {
    makeSettingSub(key, offset, value, *arr);
  } else {                                 // Normal array value
    String skey(key);
    auto& hash = arr->toArrRef().lvalAt(skey);
    forceToArray(hash);
    if (!oEmpty) {                         // a[b]
      makeArray(hash, offset, value);
    } else {                               // a[]
      hash.toArrRef().append(value);
    }
  }
}
Пример #8
0
Poco::Dynamic::Array Array::makeArray(const JSON::Array::Ptr& arr)
{
	Poco::Dynamic::Array vec;

	JSON::Array::ConstIterator it  = arr->begin();
	JSON::Array::ConstIterator end = arr->end();
	int index = 0;
	for (; it != end; ++it, ++index)
	{
		if (arr->isObject(it))
		{
			Object::Ptr pObj = arr->getObject(index);
			DynamicStruct str = Poco::JSON::Object::makeStruct(pObj);
			vec.insert(vec.end(), str);
		}
		else if (arr->isArray(it))
		{
			Array::Ptr pArr = arr->getArray(index);
			std::vector<Poco::Dynamic::Var> v = makeArray(pArr);
			vec.insert(vec.end(), v);
		}
		else
			vec.insert(vec.end(), *it);
	}

	return vec;
}
Пример #9
0
void IniSetting::SystemParserCallback::onPopEntry(const std::string& key,
                                                  const std::string& value,
                                                  const std::string& offset,
                                                  void* arg) {
  assert(!key.empty());
  if (IniSetting::s_config_is_a_constant) {
    IniSetting::config_names_that_use_constants.insert(key);
    IniSetting::s_config_is_a_constant = false;
  }
  auto& arr = *(IniSetting::Map*)arg;
  auto* ptr = arr.get_ptr(key);
  if (!ptr || !ptr->isObject()) {
    arr[key] = IniSetting::Map::object;
    ptr = arr.get_ptr(key);
  }
  if (!offset.empty()) {
    makeArray(*ptr, offset, value);
  } else {
    // Find the highest index
    auto max = 0;
    for (auto &a : ptr->keys()) {
      try {
        if (a.asInt() >= max) {
          max = a.asInt() + 1;
        }
      } catch (std::range_error const& e) { /* not an int */ }
    }
    (*ptr)[std::to_string(max)] = value;
  }
}
Пример #10
0
/*
This function adds d2 to the left of d1. This new drawing will be returned.

THIS FUNCTION ONLY WORKS WHEN THE HEIGHTS OF BOTH DRAWINGS IS THE SAME!!!

@param: drawing* d1, drawing* d2
	two drawings which will be added together
	
@return: final drawing
*/
drawing* addDrawing(drawing* d1, drawing* d2){
	drawing* finalD = (drawing*)malloc(sizeof(drawing));

	finalD->x = d1->x;//sets the location
	finalD->y = d1->y;

	finalD->width = d1->width + d2->width;//sets the dimensions
	finalD->height = d1->height;

	finalD->canvas = makeArray(finalD->width, finalD->height);


	for(int i = 0; i < d1->height; i++){//inputs the contents of d1 into the canvas
		for(int j = 0; j < d1->width; j++){
			finalD->canvas[i][j]= d1->canvas[i][j];
		}			
	}
	for(int i = 0; i < d1->height; i++){//inputs the contents of d2 into the canvas
		for(int j = d1->width; j < finalD->width; j++){
			finalD->canvas[i][j]= d2->canvas[i][j-d1->width];
		}			
	}


	return finalD;
}
Пример #11
0
Matrix makeMatrix(int rows, int cols, float v=0){
    Matrix matrix;
    for(int i = 0; i < rows; i++){
        Array a = makeArray(cols, v);
        matrix.push_back(a);
    }
    return matrix;
}
Пример #12
0
void DataStruct::expandIndirection( bool arrayind)
{
	if (m_size < 0 && m_description && m_data.ref == 0)
	{
		initStructElements();
		if (arrayind) makeArray();
	}
}
int main()
{
     /*#TS*/
     makeView("mainView", "wholeGraph","Higraph.PDV", "PlacedNode");
     setTitle("mainView", "Matrices PDV");
     setDefaultNodeValueShow(true, CENTER);
     setDefaultNodeValueColor(MARKER_RED);
     setDefaultNodeShape(RECTANGLE);
	 //ScriptManager::relay("HigraphManager", "setDefaultZoneColor", BLUE);
     ScriptManager::relay("HigraphManager", "setDefaultNodeFillColor", WHITE);
     ScriptManager::relay("HigraphManager", "setDefaultNodeValueShow", true, CENTER);
     ScriptManager::relay("HigraphManager", "setDefaultNodeValueColor", BLACK);
     ScriptManager::relay("HigraphManager", "setDefaultNodeNameShow", true, WEST);
     ScriptManager::relay("HigraphManager", "setDefaultNodeNameColor", MAGENTA);
	 ScriptManager::relay("HigraphManager", "setDefaultNodeShape", RECTANGLE);
	 ScriptManager::relay("HigraphManager","setDefaultNodeSize", 40, 40);
       
     /*#/TS*/
     const int rows = 2;
     const int cols = 3;
	 int val = 10;/*#TS*/ setupval(val);
	 /*#/TS*/
     
     int matrix[rows*cols];
     /*#TS*/makeArray(matrix,(rows*cols),true,"matrix[]");/*#/TS*/
	 int i,j;/*#TS*//*nodes for i & j*/setup_i_j(i,j);/*#/TS*/
	 
	 /*#TS*/int **mat = new int*[rows];
     for(int k=0;k<rows;k++)
        mat[k]=new int[cols];
     makeMatrix(mat,rows,cols,true,"Theoretical representation");/*#/TS*/
	 
     for(i = 0; i < rows; i++)
     {
        for(j = 0; j < cols; j++)
            {	/*#TS*/ScriptManager::relay("HigraphManager","setNodeFillColor", mat[i][j], YELLOW);
					ScriptManager::relay("HigraphManager","setNodeFillColor", matrix[(i*cols)+j], YELLOW);/*#/TS*/
				/*#TS*/	mat[i][j]=val;/*#/TS*/
                matrix[(i*cols)+j]=val++;
				/*#TS*/ScriptManager::relay("HigraphManager","setNodeFillColor", mat[i][j], WHITE);
					ScriptManager::relay("HigraphManager","setNodeFillColor", matrix[(i*cols)+j], WHITE);/*#/TS*/
			}
     }
	 
	 //Call module to add 1 to each element of matrix
	
	 add1(matrix, rows, cols);
	 
	 
	 
	 //See that the values of the original matrix have changed
     
     /*#TS*/
	 //ScriptManager::relay("HigraphManager","setNodeNameLabel",matrix,"matrix[]");
     /*#/TS*/
     return 0;
}
Пример #14
0
int main (){

	//std::tr1::array<int,3> Integer = makeArray(2,3,4);


	std::tr1::array<Obj,3> Objs = makeArray(Obj(1), Obj(2), Obj(3));

	std::cout << "1:" << Objs[0].val << " 2:" << Objs[1].val << " 3:" << Objs[2].val << std::endl;

	return 0;
}
Пример #15
0
int main(int argc, char **argv) {
	int c;
	char *file_name = NULL;
	int number_of_words = 0;
	FILE *input_file;
	while ( (c = getopt(argc, argv, "i:n:")) != -1) {
		switch (c) {
		case 'i':
			file_name = optarg;
			break;
		case 'n':
			number_of_words = atoi(optarg);
			break;
		}
	}
	if (file_name == NULL || number_of_words == 0) {
		usage(argv[0]);
		exit(EXIT_FAILURE);
	}
	input_file = fopen(file_name, "r");
	if (input_file == NULL) {
		fprintf(stderr, "Cannot open file %s\n", file_name);
		exit(EXIT_FAILURE);
	}
	while(!feof(input_file)) {
		char word[64];
		fscanf(input_file, "%s\n", word);
		toLower(word);
		printf("%s\n", word);
		struct Entry *existing = search(word);
		if (existing != NULL) {
			++existing->count;
		} else {
			struct Entry *tail = findTail();
			struct Entry *entry = malloc(sizeof(struct Entry));
			strcpy(entry->word, word);
			entry->count = 1;
			tail->next = entry;
		}
	}
	int entry_count = count();
	printf("Number of element is the list is %d\n", entry_count);
	//showAll();

	struct Entry asArray[entry_count];
	makeArray(asArray);
	qsort(asArray, entry_count, sizeof(struct Entry), cmpfunc);
	for(int i=0 ; i < entry_count ; i++) {
		struct Entry e = asArray[i];
		printf("Word: %s  Count: %d\n", e.word, e.count);
	}

	return EXIT_SUCCESS;
}
Пример #16
0
int main() {
	int tstep;
	char time_str[34];
	time_t t0;

	// Set the parameters
	int Nx, Ny, Nz, TMAX;
	Nx = 200;
	Ny = 200;
	Nz = 208;
	TMAX = 100;

	// Allocate host memory
	float ***Ex, ***Ey, ***Ez;
	float ***Hx, ***Hy, ***Hz;
	float ***CEx, ***CEy, ***CEz;
	Ex = makeArray(Nx, Ny, Nz);
	Ey = makeArray(Nx, Ny, Nz);
	Ez = makeArray(Nx, Ny, Nz);
	Hx = makeArray(Nx, Ny, Nz);
	Hy = makeArray(Nx, Ny, Nz);
	Hz = makeArray(Nx, Ny, Nz);
	CEx = makeArray(Nx, Ny, Nz);
	CEy = makeArray(Nx, Ny, Nz);
	CEz = makeArray(Nx, Ny, Nz);

	// Geometry
	set_geometry(Nx, Ny, Nz, CEx, CEy, CEz);

	// Update on the CPU
	t0 = time(0);
	for ( tstep=1; tstep<=TMAX; tstep++) {
		updateE(Nx, Ny, Nz, Ex, Ey, Ez, Hx, Hy, Hz, CEx, CEy, CEz);
		updateSrc(Nx, Ny, Nz, Ex, tstep);
		updateH(Nx, Ny, Nz, Ex, Ey, Ez, Hx, Hy, Hz);
		
		if ( tstep/100*100 == tstep ) {
			//dumpToH5(Nx, Ny, Nz, Nx/2, 0, 0, Nx/2, Ny-1, Nz-1, Ex, "cpu_png/Ex-%05d.h5", tstep);
			//exec("h5topng -ZM0.1 -x0 -S4 -c /usr/share/h5utils/colormaps/dkbluered cpu_png/Ex-%05d.h5", tstep);
			updateTimer(t0, tstep, time_str);
			printf("tstep=%d\t%s\n", tstep, time_str);
		}
	}
	updateTimer(t0, tstep, time_str);
	printf("tstep=%d\t%s\n", tstep, time_str);
}
Пример #17
0
int main()
{
	int* firstArray = makeArray(); //create array

	for (int n = 0; n < 8; n++) //display contents of array
	{
		cout << firstArray[n] << "  ";
	}
	cout << endl;

	cout << "Smallest number in array: " << smallestNumber(firstArray, 8) << endl; //display smallest number in array
}
Пример #18
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
    int nc;
    double* data;
    /* Function signature for the function handle */
    double* (*fun)(double*);
    /* Get the actual function handle back */
    fun = (double* (*)(double*)) *((mwSize*) mxGetData(prhs[0]));
    /* Call the C function through the handle and set the data*/
    data = fun(mxGetPr(prhs[2]));
    /* how much data to expect */
    nc = (int) mxGetScalar(prhs[1]);
    plhs[0] = makeArray(data,1,nc);
}
Пример #19
0
int main( int argc, void ** argv ) {
	int array_count = 20;
	int *array = makeArray( array_count );
	if( !array )
		return 0;
	
	quicksort( array, array_count );
	mergesort( array, array_count );
	heapsort( array, array_count );
	
	free( array );
	return 0;
}
Пример #20
0
void
hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
              unsigned size)
{
  PROTECT(t, map);

  object newArray = 0;

  if (size) {
    object oldArray = hashMapArray(t, map);
    PROTECT(t, oldArray);

    unsigned newLength = nextPowerOfTwo(size);
    if (oldArray and arrayLength(t, oldArray) == newLength) {
      return;
    }

    newArray = makeArray(t, newLength);

    if (oldArray != hashMapArray(t, map)) {
      // a resize was performed during a GC via the makeArray call
      // above; nothing left to do
      return;
    }

    if (oldArray) {
      bool weak = objectClass(t, map) == type(t, Machine::WeakHashMapType);
      for (unsigned i = 0; i < arrayLength(t, oldArray); ++i) {
        object next;
        for (object p = arrayBody(t, oldArray, i); p; p = next) {
          next = tripleThird(t, p);

          object k = tripleFirst(t, p);
          if (weak) {
            k = jreferenceTarget(t, k);
            if (k == 0) {
              continue;
            }
          }

          unsigned index = hash(t, k) & (newLength - 1);

          set(t, p, TripleThird, arrayBody(t, newArray, index));
          set(t, newArray, ArrayBody + (index * BytesPerWord), p);
        }
      }
    }
  }
  
  set(t, map, HashMapArray, newArray);
}
Пример #21
0
void IniSetting::ParserCallback::onPopEntry(
    const std::string &key, const std::string &value, const std::string &offset,
    void *arg) {
  Variant *arr = (Variant*)arg;
  Variant &hash = arr->lvalAt(String(key));
  if (!hash.isArray()) {
    hash = Array::Create();
  }
  if (!offset.empty()) {
    makeArray(hash, offset, value);
  } else {
    hash.append(value);
  }
}
Пример #22
0
object
growArray(Thread* t, object array)
{
  PROTECT(t, array);

  object newArray = makeArray
    (t, array == 0 ? 16 : (arrayLength(t, array) * 2));

  if (array) {
    memcpy(&arrayBody(t, newArray, 0), &arrayBody(t, array, 0),
           arrayLength(t, array));
  }

  return newArray;
}
Пример #23
0
void IniSetting::ParserCallback::onPopEntry(
    const std::string &key,
    const std::string &value,
    const std::string &offset,
    void *arg) {
  Variant *arr = (Variant*)arg;
  forceToArray(*arr);
  auto& hash = arr->toArrRef().lvalAt(String(key));
  forceToArray(hash);
  if (!offset.empty()) {
    makeArray(hash, offset, value);
  } else {
    hash.toArrRef().append(value);
  }
}
Пример #24
0
//This is where the fun part is...
char * sum(char *val0, char *val1) {
	int size;
	//getting the sizes of the passed char *str
	//so that we can find the largest one
	//and also because C doesn't have anykind of .length method
	//and sizeof returns the sizeof a pointer 
	//so we have to explicitly keep track of size
	int val0Size = getSize(val0);
	int val1Size = getSize(val1);
	//Makin' sure we've got a big enough array for the whole number.
	if (val0Size > val1Size) {
		size = val0Size;
	} else if (val1Size > val0Size) {
		size = val1Size;
	} else {
		size = val1Size;
	}
	//account for an extra zero at the beginning
	char *numArr = makeArray(val0, size);
	char *valArr = makeArray(val1, size);
	int i = size;
	for (; i >= 0; i--) {
		int numArrTmp = toInt(numArr[i]);
		int valArrTmp = toInt(valArr[i]);
		int tmp = numArrTmp + valArrTmp;
		//if tmp >= 10 we need to carry a 1 
		if (tmp >= 10) {
			numArr = addTen(numArr, i, tmp);
			//otherwise we don't
		} else {
			numArr[i] = toChar(tmp);
		}
	}
	free(valArr);
	return endCalc(numArr);
}
Пример #25
0
/*
Rotates the content counter clockwise

@param: drawing* d
*/
void rotateCcw(drawing* d){
	int max = (d->height>d->width ? d->height:d->width);

	bool** temp = makeArray(d->height, d->width);//switches width and height when mallocing

	for(int i = 0; i < max; i++){
		for(int j = 0; j < max; j++){
			temp[j][i]=d->canvas[i][j];
		}
	}

	bool** clone = d->canvas;
	d->canvas = temp;
	free(clone);

	int t = d->width;
	d->width = d->height;
	d->height = t;

	mirrorVrt(d);
}
Пример #26
0
/*
Rotates the content clockwise

@param: drawing* d
*/
void rotateCw(drawing* d){
	int max = (d->height>d->width ? d->height:d->width);//which is larger? height or width?

	bool** temp = makeArray(d->height, d->width);//switches width and height when mallocing

	for(int i = 0; i < max; i++){//replaces the columns with rows
		for(int j = 0; j < max; j++){
			temp[j][i]=d->canvas[i][j];
		}
	}

	bool** clone = d->canvas;// d is now this new drawing
	d->canvas = temp;
	free(clone);

	int t = d->width;//fixes dimensions
	d->width = d->height;
	d->height = t;

	mirrorHrz(d);//this makes it seem as though it is roatated clockwise
}
Пример #27
0
/*
Stretches Vertically the content of the drawing by a factor

@param: drawing* d
*/
void scaleVrt(drawing* d, int factor){
	d->height *= factor;

	bool** temp = makeArray(d->width, d->height);

	for(int i=0;i<d->height;i++){
		for(int j=0;j<d->width;j++){
			temp[factor*i][j] = d->canvas[i][j];
		}
	}

	for(int i=0;i<d->height*factor;i++){
		for(int j=0;j<d->width;j++){
			temp[i][j]=temp[(i/factor)*factor][j];
		}
	}

	bool** clone = d->canvas;
	d->canvas = temp;
	free(clone);
}
Пример #28
0
/*
Stretches Horizontally the content of the drawing by a factor

@param: drawing* d
*/
void scaleHrz(drawing* d, int factor){
	d->width *= factor;//fixes dimensions

	bool** temp = makeArray(d->width,d->height );

	for(int i=0;i<d->height;i++){
		for(int j=0;j<d->width;j++){
			temp[i][factor*j]=d->canvas[i][j];//this stretches the drawing, but it looks empty
		}
	}

	for(int i=0;i<d->height;i++){
		for(int j=0;j<d->width*factor;j++){
			temp[i][j]=temp[i][(j/factor)*factor];//this fill the empty gaps
		}
	}
	
	bool** clone = d->canvas;//d is now this new drawing
	d->canvas = temp;
	free(clone);
}
Пример #29
0
void drawChrc(drawing* d, char c, int boardX, int boardY){
	d->canvas = makeArray(CHRCX, CHRCY);

	d->x = boardX;
	d->y = boardY;

	d->width = CHRCX;
	d->height = CHRCY;

	if(c>='0' && c<='9'){
		drawChrc_numb(d, c-48, 0);
	}
	else if(c>='A' && c<='Z'){
		drawChrc_ucas(d, c-65, 0);
	}
	else if(c>='a' && c<='z'){
		drawChrc_lcas(d, c-97, 0);
	}
	else if(c==' '){
		drawChrc_spce(d, 0);
	}
}
Пример #30
0
void IniSetting::SystemParserCallback::onPopEntry(
    const std::string &key, const std::string &value, const std::string &offset,
    void *arg) {
  assert(!key.empty());
  auto& arr = *(IniSetting::Map*)arg;
  auto* ptr = arr.get_ptr(key);
  if (!ptr || !ptr->isObject()) {
    arr[key] = IniSetting::Map::object;
    ptr = arr.get_ptr(key);
  }
  if (!offset.empty()) {
    makeArray(*ptr, offset, value);
  } else {
    // Find the highest index
    auto max = 0;
    for (auto &a : ptr->keys()) {
      if (a.isInt() && a >= max) {
        max = a.asInt() + 1;
      }
    }
    (*ptr)[std::to_string(max)] = value;
  }
}