hey guys. im implementing a program. and i need a data structure (like queue) which should has these features;
for example user inputs an integer => x;
I have to create something like an array => array[100][m]
this is easy but i will have to shift all the elements to the next row before add a new element.
lets say:
1 2 3 4
|
m=3;
arr[0][0]=0;
arr[0][1]=0;
arr[0][2]=0;
|
then im gonna add a new serie, lets say 1,2,3. then my array should be like this:
1 2 3 4 5 6
|
arr[0][0]=1;
arr[0][1]=2;
arr[0][2]=3;
arr[1][0]=0;
arr[1][1]=0;
arr[1][2]=0;
|
(like shifting)
and the last elements of array should be deleted. i mean
arr[100][0..m]=arr[99][0..m]
- If I use array, I have to run 2 for loops for shifting before adding (this is a huge problem for me and lots of time wasting)
- If I use queue, I dont know how to use it dynamically and multidimensonally...
Because the most important about my array/queue MUST be a global struct.
I tried to explain my problem as soon as I can.
Sorry for my bad english. I hope you guys understand what i want.. Any advice?