Skip to content

make variable naming consistent across library#223

Merged
cameroncuster merged 3 commits into
devfrom
naming-consistency
Jul 6, 2026
Merged

make variable naming consistent across library#223
cameroncuster merged 3 commits into
devfrom
naming-consistency

Conversation

@cameroncuster

@cameroncuster cameroncuster commented Jul 6, 2026

Copy link
Copy Markdown
Member

Purely cosmetic pass to make variable naming consistent across the library — code and doc comments (@code examples, @param docs, READMEs were audited too). No functional or algorithmic changes; opts for the shorter form wherever two conventions coexisted.

Conventions enforced

Concept Winner Losers replaced
accumulated result res ret, ans, tmp_res
current element/value cur curr
visited marker vis seen, used
next node/child index nxt next (member arrays in tries; also avoids shadowing std::next)
pushed value val elem
priority pri priority
count of X cnt_* count_*, left_count -> cnt_l
position lists pos / pos_idx index / index_into_index

Already-consistent names (tin, siz, dp, idx, tl/tr/tm, l/r, u/v/w) were left as the established standard.

Code changes (15 files)

  • data_structures_[l,r)/bit.hpp, data_structures_[l,r]/bit.hppret -> res
  • data_structures_[l,r)/bit_uncommon/kd_bit.hppans -> res
  • data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hppleft_count -> cnt_l
  • data_structures_[l,r)/uncommon/deque_op.hppelem -> val
  • data_structures_[l,r)/uncommon/mode_query.hppindex/index_into_index -> pos/pos_idx
  • data_structures_[l,r)/uncommon/priority_queue_of_updates.hppcurr -> cur, priority param -> pri (in code, @param, and @code example)
  • flow/hungarian.hppused -> vis
  • graphs/uncommon/enumerate_triangles.hppseen -> vis
  • math/count_paths/count_paths_rectangle.hppret/res/tmp_res -> res/cur/tmp
  • math/num_distinct_subsequences.hppcurr -> cur
  • strings/trie.hpp, strings/binary_trie.hppnext member -> nxt
  • tests/.../binary_trie.test.cpp — updated for the nxt member rename

Doc-comment changes

  • graphs/bcc_callback.hpp@code example: seen/count_edges -> vis/cnt_edges
  • dsu/line_tree.hpp@code example: next -> nxt
  • priority_queue_of_updates.hpp@code/@param: curr_pri/priority -> pri (example was also rewritten upstream in fix doc nits #220; kept the new version with pri)

Full sweep of all @code...@endcode blocks and repo READMEs confirms no remaining occurrences of the replaced names.

Verification

  • clang-format --dry-run --Werror passes with dev.clang-format on all changed files
  • All 20 affected test files compile clean with g++ -std=c++20 -O2 -Wall -Wextra
  • Merged latest dev (includes fix doc nits #220 doc nits and pass recursive lambda self param by reference #222 recursive-lambda change); the one conflict (priority_queue_of_updates.hpp doc example) resolved in favor of dev's rewritten example with the pri naming applied

Cameron Custer added 3 commits July 6, 2026 10:30
@cameroncuster cameroncuster merged commit 962f6a6 into dev Jul 6, 2026
7 of 8 checks passed
@cameroncuster cameroncuster deleted the naming-consistency branch July 6, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant