Adding bucket interface for std::deque?

67 views
Skip to first unread message

eulo...@live.com

unread,
Oct 20, 2017, 12:19:54 AM10/20/17
to ISO C++ Standard - Future Proposals
we have bucket interface for std::unordered_map. What about adding bucket interface for std::deque?

using local_iterator = implementation defined 
using const_local_iterator = implementation defined

returns an iterator to the beginning of the specified bucket
(public member function)
returns an iterator to the end of the specified bucket
(public member function)
returns the number of buckets
(public member function)
returns the maximum number of buckets
(public member function)
returns the number of elements in specific bucket
(public member function)

pointer data(size_type)
const_pointer data(size_type) const

  returns an pointer to the beginning of the specified bucket for passing C Interfaces

Richard Smith

unread,
Oct 20, 2017, 6:03:38 PM10/20/17
to std-pr...@isocpp.org
On 19 October 2017 at 21:19, <eulo...@live.com> wrote:
we have bucket interface for std::unordered_map. What about adding bucket interface for std::deque?

Can you give some motivating examples where this would be valuable?
 
using local_iterator = implementation defined 
using const_local_iterator = implementation defined

returns an iterator to the beginning of the specified bucket
(public member function)
returns an iterator to the end of the specified bucket
(public member function)
returns the number of buckets
(public member function)
returns the maximum number of buckets
(public member function)
returns the number of elements in specific bucket
(public member function)

pointer data(size_type)
const_pointer data(size_type) const

  returns an pointer to the beginning of the specified bucket for passing C Interfaces

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2090dc14-35d4-4e9c-85c5-d25b3598ad17%40isocpp.org.

Nicol Bolas

unread,
Oct 20, 2017, 11:54:02 PM10/20/17
to ISO C++ Standard - Future Proposals
On Friday, October 20, 2017 at 12:19:54 AM UTC-4, ejsvifq mabmip wrote:
we have bucket interface for std::unordered_map. What about adding bucket interface for std::deque?

To have a "bucket interface", you need to first have the idea that buckets exist at all.

Unordered containers have bucket interfaces because they have buckets as a first-class concept. There are ways to control how many buckets exist and so forth. This is not the case for a `deque`. The number of buckets is essentially an accident of the implementation. For example, if the number of items per bucket in an implementation is 10, and you put 12 elements in a `deque`, how many buckets are there? Well, it could be as many as 3, depending on how you inserted them.

Equally importantly, how would that even work? Which bucket is referred to by index 0? If you insert a bunch of items at the beginning, is index 0 still referring to the same bucket anymore? Remember: a `deque` is a "double-ended queue"; the whole point of the type is that insertion/removal from the ends doesn't affect iteration. There's pretty much no way to provide that with so-called bucket iterators.













Reply all
Reply to author
Forward
0 new messages