@@ -19,11 +19,10 @@ However the approach to implementation necessary to support 8/16-bit
1919types without artificially widening the type storage, as described under
2020<a href =" https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0447r28.html#non_reference_implementations_info" >
2121"Additional info for supporting small types" in P0447</a > basically specifies
22- time complexity which is `Log(n)` in the capacity of the element block selected
23- to insert into (when erased element memory locations are available for reuse) but
24- imposes a small maximum block capacity cap. This time complexity only occurs
22+ time complexity which is `Log(n)` (on most platforms, log64 or log32) in the
23+ capacity of the element block selected to insert into. This time complexity only occurs
2524during the operation to find an erased element memory location within a block
26- which is known to have one.
25+ which is known to have one, and does not involve the elements themselves .
2726<p />
2827This is both the simplest and fastest solution to supporting small types
2928in hive without artificial widening that I have come across.
@@ -37,58 +36,21 @@ and other memory-scarse platforms as it reduces the 16-bit-per-element cost of t
3736reference implementation down to a 1-bit-per-element cost. For 64-bit and larger types,
3837there are other ways to obtain this reduction without
3938losing <tt >𝒪 (1)</tt > lookup but it is unclear whether those methods would
40- in fact be faster.
39+ in fact be faster. For approaches involving bitset-stacking, the logarithmic
40+ complexity also occurs during erasure, specifically adding a couple of extra
41+ instructions for every 64x (i.e. bit-depth) increase in block capacity. But again
42+ this does not involve the elements and is logarithmic in the capacity of the block
43+ erased from.
4144<p />
42- There is ambiguity as to whether this should result in a change to <tt >hive::insert/emplace</tt >
45+ Regardless, the increased complexity during insertion is necessary for small-type support.
46+ <p />
47+ There was ambiguity as to whether this should result in a change to <tt >hive</tt >
4348time complexity when discussed on the reflector, as it is unrelated to element numbers (unless
4449all elements fit within one block), but it is related to block capacities, which are defined
4550as part of the `hive` technical specification.
4651</p >
47- <p >
48- <b >Changes necessary:</b >
49- <p />
50- Making this change would affect any functions which may reuse existing
51- erased-element memory locations. This includes:
52- <p />
53- <sref ref =" [hive.modifiers]" />:<br />
54- (`emplace`) p4<br />
55- (range `insert`) p9<br />
56- (fill `insert`) p13
57- <p />
58- <sref ref =" [hive.capacity]" />:<br />
59- (`shrink_to_fit`) p10<br />
60- (`reshape`) p24
61- <p />
62- (both of the above functions may potentially relocate existing elements
63- from one block to erased element locations in another)
64- <p />
65- <sref ref =" [hive.cons]" />:<br />
66- (<tt >operator= & </tt >) p27<br />
67- (<tt >operator= && </tt >) p31
68- <p />
69- (move assignment will switch to moving individual elements where
70- allocators are not equal - and in the case of non-trivial/allocating
71- types, move-assigning to existing elements in the source may be beneficial)
72- <p />
73- In addition, if we were to support bitset-stacking approaches these also
74- effect functions which erase individual elements. This includes:
75- <p />
76- <sref ref =" [hive.modifiers]" />:<br />
77- (`erase`) p16
78- <p />
79- <sref ref =" [hive.operations]" />:<br />
80- (`unique`) p11
81- </p >
8252
83- <blockquote class =" note" >
84- <p >
85- This issue has some overlap to LWG <iref ref =" 4323" />, and it would
86- affect the outcome wording of that issue for `unique`.
87- </p >
88- </blockquote >
89- </discussion >
90-
91- <resolution >
53+ <superseded >
9254<p >
9355This wording is relative to <paper num =" N5014" />.
9456</p >
@@ -342,6 +304,59 @@ at worst <tt>𝒪(log n)</tt> in the capacity of each block containing the
342304
343305</li >
344306
307+ </ol >
308+ </superseded >
309+
310+ <note >2025-09-26; Matt comments and provides improved wording</note >
311+ <p >
312+ Past LWG/LEWG telecon discussion around this topic concluded that because elements are not involved,
313+ and the logarithmic action is within the capacity of a block (a fixed number), not the size of the
314+ sequence, and the actual performance cost is negligible, that the complexity of these actions are
315+ in fact constant. But there is some disagreement on this.
316+ <p />
317+ One possibility is to add additional complexity data to each of the effected functions. This would
318+ impact on `emplace`, range `insert`, fill `insert`, `shrink_to_fit`, `reshape`, copy/move
319+ assignment operator, `erase` and `unique`. However I feel this is overkill and may confuse
320+ implementors as the log(n) complexity is not permitted to involve elements.
321+ <p />
322+ Having looked into it and sought feedback I think a blanket note on <sref ref =" [hive.overview]" /> p3
323+ would be sufficient, such that the time complexity is limited to "techniques to identify the memory
324+ locations of erased elements". Otherwise we need to stay with the previous resolution that this
325+ is in fact constant time behaviour.
326+ </p >
327+ </discussion >
328+
329+ <resolution >
330+ <p >
331+ This wording is relative to <paper num =" N5014" />.
332+ </p >
333+
334+ <ol >
335+
336+ <li ><p >Modify <sref ref =" [hive.overview]" /> as indicated:</p >
337+
338+ <blockquote >
339+ <p >
340+ -1- A `hive` is a type of sequence container that provides constant-time insertion and erasure
341+ operations. Storage is automatically managed in multiple memory blocks, referred
342+ to as element blocks. Insertion position is determined by the container, and
343+ may re-use the memory locations of erased elements.
344+ <p />
345+ -2- [… ]
346+ <p />
347+ -3- Erasures use unspecified techniques <del >of constant time complexity</del > to identify the memory
348+ locations of erased elements, which are subsequently skipped during iteration <ins >in constant time</ins >,
349+ as opposed to relocating subsequent elements during erasure. <ins >The same or different techniques
350+ may be utilized to find and re-use these locations during subsequent insertions.</ins >
351+ <p />
352+ <ins >[<i >Note</i >: The techniques are permitted to be at worst logarithmic in the capacity of the
353+ element blocks being inserted into or erased from while maintaining constant-time iteration, to allow
354+ latitude for implementation-specific optimizations. — <i >end note</i >]</ins >
355+ </p >
356+ </blockquote >
357+
358+ </li >
359+
345360</ol >
346361</resolution >
347362
0 commit comments