I'm looking for the best way to perform this task in Python 2.x
I have an array of given size, with some element that have to stay at given position identified by attribute.
I have to remove an element from the array, and move all the non fixed elements to the top, and fill the missing bottom entry with a copy of the first entry.
Example
Starting array:
array[0]={property='dynamic', name='A'}
array[1]={property='dynamic', name='B'}
array[2]={property='fixed', name='C'}
array[3]={property='dynamic', name='D'}
array[4]={property='fixed', name='E'}
array[5]={property='dynamic', name='F'}
Remove one item
array[0]={property='dynamic', name='A'}
array[1]={property='dynamic', name='B'}
array[2]={property='fixed', name='C'}
array[4]={property='fixed', name='E'}
array[5]={property='dynamic', name='F'}
Move non fixed elements to top
array[0]={property='dynamic', name='A'}
array[1]={property='dynamic', name='B'}
array[2]={property='fixed', name='C'}
array[3]={property='dynamic', name='F'}
array[4]={property='fixed', name='E'}
end result filling last missing slot with top element
array[0]={property='dynamic', name='A'}
array[1]={property='dynamic', name='B'}
array[2]={property='fixed', name='C'}
array[3]={property='dynamic', name='F'}
array[4]={property='fixed', name='E'}
array[5]={property='dynamic', name='A'}
What could be the fastest way to do this ? (property, array size and elements are all dynamics)