CUnitSet

CUnitSet

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Misolavera
Posts: 8
Joined: 20 Aug 2014, 22:21

CUnitSet

Post by Misolavera »

Hello,

While reading the code, I wanted to find out how units where managed on memory side.
I found out it was a container defined according to this :
https://github.com/spring/spring/blob/d ... /UnitSet.h
Please tell me if I'm mistaking.

Why is it a std::set ? which is an ordered container which mean every insert/delete is in O(log(n)) unless you give an iterator/pointer to the contained object (a pointer to a CUnit*) in which case it is in O(1).
http://en.cppreference.com/w/cpp/container/set

Why not an unordered_set ? http://en.cppreference.com/w/cpp/contai ... rdered_set
Do you really have a need for ordered pointers ?

If you do not have a c++11 compliant compiler, there is still http://www.boost.org/doc/libs/1_56_0/do ... d_set.html
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: CUnitSet

Post by jK »

The iteration of that container have to be a fixed order on all computers for syncing reasons, also check the comparison operator (it compares ids, not pointer locations).
Misolavera
Posts: 8
Joined: 20 Aug 2014, 22:21

Re: CUnitSet

Post by Misolavera »

Ok, the id comparison was my next question.

Before asking, I did try to figure out where CUnitSet was used with a notepad++ Ctrl+F to list everything and did not saw anything except for group handling, selecting and list in Team (mainly).

I did not worked out how Sync works.
Post Reply

Return to “Engine”