PARTIAL 325 Fix - HashTableAnalysis C++ example - #1137
Conversation
|
I like this, but the code takes advantage of Note: I believe it probably should be, but we need to make sure to cover it when we discuss types (we need to be sure to demonstrate that discussion on #943 |
|
@wrigjl Good catch. I missed that. I think that auto should be introduced, but it is not necessary here. What about explicitly using the actual data type here?
|
|
Here is a nice discussion about the downsides of overusing https://gist.github.com/Eisenwave/5cca27867828743bf50ad95d526f5a6e |
|
@wrigjl what do you think about using the following at least temporarily?
|
|
It's also a chance to demonstrate that namespaces compose (at most an
aside).
…On Tue, Aug 25, 2026, 4:27 PM Jan Pearce ***@***.***> wrote:
*pearcej* left a comment (pearcej/cppds#1137)
<#1137 (comment)>
@wrigjl <https://github.com/wrigjl> what do you think about using the
following at least temporarily?
chrono::steady_clock::time_point begin = chrono::steady_clock::now();
time_point can be meaningful vocabulary, telling students that begin
represents a point in time according to the steady clock.
—
Reply to this email directly, view it on GitHub
<#1137?email_source=notifications&email_token=AAFFW67G7TYRTB3NYHK3P4D5LWNZJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNBRGE3TKMZTGU4KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-5411753358>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFFW66WOQJHFNBMRW2W24T5LWNZJAVCNFSNUABFKJSXA33TNF2G64TZHMYTGMZXGMYTQNBWHNEXG43VMU5TKMJTGUYDGNJWGI32C5QC>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AAFFW66WQIYUPK3G2GSKJDD5LWNZJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNBRGE3TKMZTGU4KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AAFFW66JYPWBXR6T2BUUKXT5LWNZJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNBRGE3TKMZTGU4KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Description
Fixes the C++ example and accompanying text in Section 2.8 (Hash Table Analysis). The example previously measured the wrong thing and didn't match the surrounding prose or the figure.
fixes #325
What's fixed
Documentation accuracy
std::vectorhas nocontainsmethod; the example usesstd::findfor the vector andfind/containsfor the hash table.Timing correctness
a(container size) to report the average time per single search operation, rather than the cumulative time of searching every element. This is what the "Time to Complete Contains Operation" framing in the text (and prior figure) actually describes, and it produces the correct O(n) / O(1) trend instead of an O(n²) cumulative total for the vector case.What's left to do
Figure (
fig-vectvshash-cpp) — not included in this PRvectvshash.pngreflects the old, incorrect cumulative-timing measurement (0–50 second scale) and no longer matches the corrected code's output (nanosecond/microsecond scale).<figure>block and removed its<xref>from the prose so the doc builds cleanly without a misleading image.vectvshash.png, after which the figure block can be uncommented and the xref restored.How this was verified
I compiled and ran the corrected code locally (g++,
-O2 -std=c++17) across the full range (10,000 to 990,000 elements, step 20,000) to confirm the fix actually produces the expected trend before writing up the results in the text.This is the run that replaced the old cumulative-timing approach (which summed the time to search every element rather than averaging per-operation time, and produced a misleading result that didn't match the O(n)/O(1) claims in the text).
Tested on local build
Reviewed by @harrisonj2-v