Thanks for the help, everyone really helped (no)
- oneYou know better how to make a constructor. This is your class, isn't it? :) - Vlad from Moscow
- I do not understand the algorithm, the principle of distribution, how to select blocks in the middle, etc. - Aga
- Read the source on the basis of which you are going to make a program. - Vlad from Moscow
- very helpful, thank you (no) - Aha
- oneThe fact is that the question is too general. You did not provide any class declaration and, in general, not a single line of code. Therefore, if the question is about the algorithm, then read the literature on this algorithm. And it’s abstract to say how you should have a constructor defined, this is not serious, since the constructor’s definition depends on the class and its behavior. - Vlad from Moscow
1 answer
The question is really quite blurred. I propose at first to independently comb it in terms of the terms and entities used. They say "in the correctly asked question - contains 50% of the correct answer"
Well, by the fact that there is - in the form of assumptions ...
Once the question is marked with the tag "c ++", it is logical to assume the use of the capabilities of the "c ++" itself (as a superset of C) and / or STL.
If you want to implement "Dec based on a segmented array" based on STL, read the description of std :: deque and std :: allocator . Trying to implement your allocator.
If you want to implement "Dec based on a segmented array" without using STL, look for and read online about " placement new ".
The question of the "policy of placement" of elements with the help of the above allocators or placement new remains untested ...
It turns out the blocks begin to stand out in the middle of the directory to leave room for new blocks.
And this is how to program. However, you may need:
- The size of the "one" where we will allocate
- List of unallocated blocks "there"
- The mechanism for solving the question "what if the unallocated blocks run out?"
The implementation of the “List of unallocated blocks” directly depends on, let's say, the use forecast. In STL, different containers behave differently (in speed) when accessing, inserting, deleting, adding. There should already be more visible to the developer under the terms of a real task - what kind of containers for this use.
Something like that. What is the question - that is the answer :)
- I added a question - aha