20.09.2018, 18:32
let's say i have an array of 5 integers like this:
pos 0: 100
pos 1: 200
pos 2: 300
pos 3: 400
pos 4: 500
now i need to insert another integer with value 50 at "pos 0" but i want all of the values to remain except the last one, so the array will look like this:
pos 0: 50
pos 1: 100
pos 2: 200
pos 3: 300
pos 4: 400
so basically everything should shift the position by 1 to make space for the new value
is there some technique to do this fast and easy?!
pos 0: 100
pos 1: 200
pos 2: 300
pos 3: 400
pos 4: 500
now i need to insert another integer with value 50 at "pos 0" but i want all of the values to remain except the last one, so the array will look like this:
pos 0: 50
pos 1: 100
pos 2: 200
pos 3: 300
pos 4: 400
so basically everything should shift the position by 1 to make space for the new value
is there some technique to do this fast and easy?!