You can't push
to an array of fixed size. (The code you wrote above would not compile.)
push
modifies an array's size, so it's an operation that doesn't make sense for a fixed-size array. It only exists for dynamic arrays.
UPDATE
I believe that delete Arr[0]
is equivalent to Arr[0] = 0
, so it's also not doing anything useful for you.
If you explain what you're trying to do, perhaps people can help more. (It looks like you're trying to implement a deque using a fixed-size array? But what is supposed to happen when you run out of space?)
UPDATE 2
Per the comments, it sounds like you just want a regular circular buffer.
Untested, but I believe this should work:
pragma solidity ^0.4.17;
contract CircularBuffer {
uint[100] Arr;
// Represents the index in the array of the oldest element
uint8 start;
// Represents the next position to write to
uint8 end;
// Represents the size of the data (max of 100)
uint8 size;
function append(uint value) public {
Arr[end] = value;
end = (end + 1) % 100;
if (size < 100) {
size += 1;
} else {
// start was just overwritten
start = (start + 1) % 100;
}
}
function enumerate() public {
for (uint8 i = 0; i < size; i++) {
uint value = Arr[(start + i) % 100];
// do something with value here
}
}
}