A Nim seq stores its entries in a consecutive memory area indeed. If you want 
to delete an arbitrary element, you have two possibilities: If you need to keep 
order, maybe as seq is sorted, you move all elements after the element do 
delete one position forward, which is a mem copy. Or, if order is not 
important, you can move last element in seq to place of element to delete. In 
all cases you have to set new length to len - 1 of course. We have del() and 
delete() for this. When you have to move, moving pointers is only 4 or 8 bytes 
each, and moving value objects is moving size of object each. So for really 
large elements moving pointers is faster of course. But generally a memcopy is 
very fast.

Pointers can be moved faster in seq maybe, but when you access the elements, 
then pointers are a indirection, and generally when you use pointers, then the 
elements itself may be distributed in Ram, so that there is nearly no cache 
support even when you process the data in consecutive order. 

Reply via email to