Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hamt: Add public fn clear to reset and clear all entries in HAMT #2095

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

snissn
Copy link
Contributor

@snissn snissn commented Dec 4, 2024

following up on changes to the KAMT in #2092 this PR changes HAMT to support a clear() method

This PR introduces a new clear method to the Hamt data structure, allowing users to reset the root to an empty node and clear all entries.

Changes:

  • Added pub fn clear to Hamt to reset and clear all entries.
  • Updated the test suite with test_clear to verify:
    • Entries exist before clearing.
    • Entries are removed after calling clear.
    • The Hamt remains functional post-clear.

This addition enhances usability by providing an efficient way to clear the Hamt.

@snissn snissn requested a review from Stebalien December 4, 2024 17:15
@codecov-commenter
Copy link

codecov-commenter commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.95%. Comparing base (e9eef91) to head (7e65b56).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2095      +/-   ##
==========================================
+ Coverage   75.86%   75.95%   +0.09%     
==========================================
  Files         154      154              
  Lines       15743    15778      +35     
==========================================
+ Hits        11943    11984      +41     
+ Misses       3800     3794       -6     
Files with missing lines Coverage Δ
ipld/hamt/src/hamt.rs 90.99% <100.00%> (+3.49%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Stebalien Stebalien merged commit cf6771a into master Dec 4, 2024
14 checks passed
@Stebalien Stebalien deleted the mikers/HAMT-clear branch December 4, 2024 19:20
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.

3 participants