@Koshling, I had a headache, so I was little undirect. Those landmarks are not so static as I thought. They can be removed -- for example on forest removal -- and I would say, theoretically they should be addable in future -- like on forest planting, nuking, terraforming. So I think an ordinary array is too weak for it. I quite dislike FFreeListTrashArray too, so I've been thinking about an alternative. And I think, I can have one which may be sightly better. Please say me, do you think.
* it would not need heap allocation for each new element (now each element is allocated separately)
* growing would take constant time
* there would be a lost of memory for buffering. This would reach maximally size of one block, where we can set this size (15MB?), and be linearly lower for less filled arrays
* adding a new element would take constant time. It would involve copying one additional element. Yes, whole element not only a wrapper. But I believe memcpy can do it quite fast
* removing would take constant time. It would involve copying 1-2 additional elements
* it would be able to shrink. And it would also be magically done in constant time
* it would provide a class for references to elements (encapsulated pointer), which will be able to be dereference without a need to point the storage structure
* it would ensure not reading an overridden element as the old one. Now there is a small chance for this
* it could possibly be sightly bigger then FFreeListTrashArray. Like 4-8 bytes per element. But the references would be smaller then IDInfos and the heap allocation mechanism would not eat our memory
Thinking, when the system memory is nearly full, heap allocation may be space ineffective due to fragmentation. Or time ineffective, if it uses some on-fly defragmentation. This can be a win. However, have not enough experience to be sure.
Oh my. What a technical talk. I think, I will need to cock something now, to bring some balance to my brain.
* it would not need heap allocation for each new element (now each element is allocated separately)
* growing would take constant time
* there would be a lost of memory for buffering. This would reach maximally size of one block, where we can set this size (15MB?), and be linearly lower for less filled arrays
* adding a new element would take constant time. It would involve copying one additional element. Yes, whole element not only a wrapper. But I believe memcpy can do it quite fast
* removing would take constant time. It would involve copying 1-2 additional elements
* it would be able to shrink. And it would also be magically done in constant time
* it would provide a class for references to elements (encapsulated pointer), which will be able to be dereference without a need to point the storage structure
* it would ensure not reading an overridden element as the old one. Now there is a small chance for this
* it could possibly be sightly bigger then FFreeListTrashArray. Like 4-8 bytes per element. But the references would be smaller then IDInfos and the heap allocation mechanism would not eat our memory
Thinking, when the system memory is nearly full, heap allocation may be space ineffective due to fragmentation. Or time ineffective, if it uses some on-fly defragmentation. This can be a win. However, have not enough experience to be sure.
Oh my. What a technical talk. I think, I will need to cock something now, to bring some balance to my brain.