shifting 2D array values

I have several sensors on my arduino that I would like to log
Data comes from the Arduino in the form of a string and is formatted in the following manner (there are 6 fields)
"10.2", "123.33", "0.00", "1023.00", "99.01", "256.9"/r

in processing I am reading the string then splitting and converting it in to a float and that seems to be working fine.

What I need to do is store the information in an array so I can output the information however I also need to be able to shift the last readings in and out as I would like to keep track of the last 60 values for each sensor.

for example

{0}, {0, 1, 2, 3, -> whatever the incoming values are etc-> 58, 59, 60};
When a new value comes in the new values is added and shifted to the left.
{0}, {1, 2, 3, 4, -> whatever the incoming values are etc-> 59, 60, 61};

Ideally i would like to do this without using loops as some of the other functions are kind of time critical.

I hope that made sense and thanks in advance for any assistance or ideas on this.

There are probably other ways, but this might be one:

void setup() {
  int numbers[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  int arraySize = sizeof(numbers) / sizeof(numbers[0]);
  Serial.begin(9600);
  
  Serial.println("Original:");

  for (int i = 0; i < arraySize; i++) {           // Show original array
    Serial.print(numbers[i]);
    Serial.print(" ");
  }
  Serial.println();
  
  memmove(numbers, &numbers[1], sizeof(numbers)); // Work done here
  numbers[arraySize - 1] = 111;                   // New value

  Serial.println("Reordered:");
  for (int i = 0; i < arraySize; i++) {           // Show new array
    Serial.print(numbers[i]);
    Serial.print(" ");
  }
}

void loop() {
}

econjack:
There are probably other ways, but this might be one:

  memmove(numbers, &numbers[1], sizeof(numbers)); // Work done here

[/quote]

Thanks for that, I knew there had to be a way to do this without having to loop through the array and copy each table over :slight_smile: I am trying to keep the performance and speed of things as high as possible and trying to stay away from having to use loops as much as I can

The truth is that many of the mem*() function do use loops, but they are often written in hand-tweaked assembler and usually do not implement any boundary or other checks. As a result, they are usually about as efficient as you can do the task at hand. Just keep in mind the functions are as dumb as a bunch of rocks and do not protect you from anything.