Home » U++ Library support » U++ Core » T* Detach() for ArrayMap
|
|
Re: T* Detach() for ArrayMap [message #24883 is a reply to message #24881] |
Wed, 03 February 2010 06:57   |
 |
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
you're absolutely right, this one's better. should have looked before..
the goal was just to be able to switch from Array to ArrayMap, when i.e one gets the impression, well i need to speed up things, or need to change stuff, so just to enhance it in one place, and supply the keys in the other places, without the need of doing lot of workarounds to replace missing behaviour.
Detach() slowness was not the main goal in that, though having it done faster is precious. one should at least be able to separate an obejct from a ArrayMap again (which maybe were constructed outside the map and added).
this kind of aproach is not possible for Vector and VectorMap though, the objects are stored on a consequtive mem space, which can only be Removed(). but Vector/VectorMap requires to have a Mouvable object (objects are reorganized on storage space during growth/shrink of vector), so why not having same Detach() also here? which would simply copy the stored object to a decent new place and return pointer? maybe because its no real "detach".. but it would make life esier, when exchanging vector to array, array to map or waht ever. dont know for sure if it makes sense.
DetachUnlink also makes sense, to say simply "stay in background until reactivated..".. but how would you reactivate such one?
|
|
|
Re: T* Detach() for ArrayMap [message #24890 is a reply to message #24883] |
Wed, 03 February 2010 11:24   |
 |
mirek
Messages: 14256 Registered: November 2005
|
Ultimate Member |
|
|
kohait00 wrote on Wed, 03 February 2010 00:57 | you're absolutely right, this one's better. should have looked before..
the goal was just to be able to switch from Array to ArrayMap, when i.e one gets the impression, well i need to speed up things, or need to change stuff, so just to enhance it in one place, and supply the keys in the other places, without the need of doing lot of workarounds to replace missing behaviour.
Detach() slowness was not the main goal in that, though having it done faster is precious. one should at least be able to separate an obejct from a ArrayMap again (which maybe were constructed outside the map and added).
this kind of aproach is not possible for Vector and VectorMap though, the objects are stored on a consequtive mem space, which can only be Removed(). but Vector/VectorMap requires to have a Mouvable object (objects are reorganized on storage space during growth/shrink of vector), so why not having same Detach() also here? which would simply copy the stored object to a decent new place and return pointer?
|
It is not quite typical situation. If you really need something like that, you can use Swap, which leads to similar results...
Quote: |
DetachUnlink also makes sense, to say simply "stay in background until reactivated..".. but how would you reactivate such one?
|
Good point 
Mirek
|
|
|
|
Goto Forum:
Current Time: Fri May 02 13:50:21 CEST 2025
Total time taken to generate the page: 0.03086 seconds
|