Date: Wed, 12 Feb 2025 05:06:40 +0300
*[[[[My comments in bold]]]]*
вт, 11 февр. 2025 г. в 22:04, Jonathan Wakely <cxx_at_[hidden]>:
>
>
> On Tue, 11 Feb 2025 at 18:33, Александр Поваляев via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> *[[[My comments in bold]]]*
>>
>> вт, 11 февр. 2025 г. в 21:06, Bo Persson via Std-Proposals <
>> std-proposals_at_[hidden]>:
>>
>>> On tis 2025-02-11 at 09:29, Александр Поваляев via Std-Proposals wrote:
>>> > A Proposal to Add a New Multiset container Method to the Standard
>>> > Library Technical Report
>>> >
>>>
>>> > C++ Containers library std::multiset
>>> >
>>> > (1) size_type reduce( const Key& key );
>>> >
>>> > (2)
>>> > template< class K >
>>> > size_type reduce( K&& x );
>>> >
>>> > (3) size_type reduce( const Key& key, size_type count );
>>> >
>>> > (4)
>>> > template< class K >
>>> > size_type reduce( K&& x, size_type count );
>>> >
>>> > This method acts in right the opposite way to how method 'insert'
>>> does.
>>> > Method 'reduce' decreases the number of std::multiset elements with
>>> > the same key value. And while being supplied within the second
>>> argument
>>> > 'size_type count', method 'reduce' decreases the number of
>>> std::multiset
>>> > elements with the same key value but several times.
>>> >
>>>
>>> How do we know if the function is to remove the oldest or the newest
>>> inserts? Or some in the middle?
>>>
>> *[[[Aleksandr]]] I believe it should be in the priority queue like
>> style. *
>>
>
> No, there is no priority here.
>
>
>> *https://en.cppreference.com/w/cpp/container/multiset
>> <https://en.cppreference.com/w/cpp/container/multiset> says "*
>>
>> *The order of the elements that compare equivalent is the order of
>> insertion and does not change.*
>> *(since C++11)**", so the oldest inserts should be deleted.*
>>
>
> It doesn't say anything about "oldest". You cannot know which are the
> "oldest", you can only know which are the closest to the beginning of the
> container.
>
> If you insert every equivalent element using a hint, you can put the newer
> elements before the older ones, or after them. So the order of equivalent
> elements is not in oldest to newest, or newest to oldest. It depends on how
> they were inserted.
>
[[[[Aleksandr]]]] "The order of the elements that compare equivalent is the
order of insertion and does not change" (
https://en.cppreference.com/w/cpp/container/multiset) means that an element
which is inserted first will be the closest to the beginning of the
container amongst all the elements with the same key value. And so, it will
be the first element to be deleted by a 'reduce' method call.
Let's call such an element as "oldest" amongst all the elements within the
same key value.
вт, 11 февр. 2025 г. в 22:04, Jonathan Wakely <cxx_at_[hidden]>:
>
>
> On Tue, 11 Feb 2025 at 18:33, Александр Поваляев via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> *[[[My comments in bold]]]*
>>
>> вт, 11 февр. 2025 г. в 21:06, Bo Persson via Std-Proposals <
>> std-proposals_at_[hidden]>:
>>
>>> On tis 2025-02-11 at 09:29, Александр Поваляев via Std-Proposals wrote:
>>> > A Proposal to Add a New Multiset container Method to the Standard
>>> > Library Technical Report
>>> >
>>>
>>> > C++ Containers library std::multiset
>>> >
>>> > (1) size_type reduce( const Key& key );
>>> >
>>> > (2)
>>> > template< class K >
>>> > size_type reduce( K&& x );
>>> >
>>> > (3) size_type reduce( const Key& key, size_type count );
>>> >
>>> > (4)
>>> > template< class K >
>>> > size_type reduce( K&& x, size_type count );
>>> >
>>> > This method acts in right the opposite way to how method 'insert'
>>> does.
>>> > Method 'reduce' decreases the number of std::multiset elements with
>>> > the same key value. And while being supplied within the second
>>> argument
>>> > 'size_type count', method 'reduce' decreases the number of
>>> std::multiset
>>> > elements with the same key value but several times.
>>> >
>>>
>>> How do we know if the function is to remove the oldest or the newest
>>> inserts? Or some in the middle?
>>>
>> *[[[Aleksandr]]] I believe it should be in the priority queue like
>> style. *
>>
>
> No, there is no priority here.
>
>
>> *https://en.cppreference.com/w/cpp/container/multiset
>> <https://en.cppreference.com/w/cpp/container/multiset> says "*
>>
>> *The order of the elements that compare equivalent is the order of
>> insertion and does not change.*
>> *(since C++11)**", so the oldest inserts should be deleted.*
>>
>
> It doesn't say anything about "oldest". You cannot know which are the
> "oldest", you can only know which are the closest to the beginning of the
> container.
>
> If you insert every equivalent element using a hint, you can put the newer
> elements before the older ones, or after them. So the order of equivalent
> elements is not in oldest to newest, or newest to oldest. It depends on how
> they were inserted.
>
[[[[Aleksandr]]]] "The order of the elements that compare equivalent is the
order of insertion and does not change" (
https://en.cppreference.com/w/cpp/container/multiset) means that an element
which is inserted first will be the closest to the beginning of the
container amongst all the elements with the same key value. And so, it will
be the first element to be deleted by a 'reduce' method call.
Let's call such an element as "oldest" amongst all the elements within the
same key value.
Received on 2025-02-12 02:06:57