Is there anything preventing this?
A more narrow definition would limit this to be done only at the beginning or the end of the deque (splice_back/splice_front).
--Adi
Since deque is internally a doubly linked list of blocks, why not add a new method list std::splice that will concatenate one deque at the end of the other in constant time by splicing the internal lists?
This should be feasible to do in constant time regardless of the size of the containers.Is there anything preventing this?
Ignoring the fact that implementations are allowed to implement deque however they want, even in a linked-list implementation what you want simply can't happen.
The reason being that only the first and last blocks in a deque are allowed to be partially empty.
This would only be necessary where "splice" exists. And it would needlessly take up performance from any `deque` user who doesn't use "splice", since every block access has to check the two indices to tell where the valid elements are.
--
---
You received this message because you are subscribed to a topic in the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this topic, visit https://groups.google.com/a/isocpp.org/d/topic/std-proposals/hPHs98Z7X-g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
> why not add a new method list std::splice that will concatenate one deque at the end of the other in constant time by splicing the internal lists?
> This should be feasible to do in constant time regardless of the size of the containers.
Given a spliced deque with gaps in the middle, finding the n'th element would not be constant-time.
> This should be feasible to do in constant time regardless of the size of the containers.
Given a spliced deque with gaps in the middle, finding the n'th element would not be constant-time.Yes, that is exactly what I meant.
On 2015–10–01, at 4:59 PM, Dietmar Kühl <dietma...@gmail.com> wrote:Neither `splice()` nor `push_back()` on a `std::deque<T>` can be done in worst case O(1) complexity. There are O(1) operations on `T` objects but the outer array contains O(n) pointers to inner arrays and upon appending it may require O(n) operations to move them to a new location.