Skip to content

feat(sorted_map): add get_or_init and get_or_default#3316

Merged
bobzhang merged 2 commits intomainfrom
hongbo/sorted-map-api
Mar 19, 2026
Merged

feat(sorted_map): add get_or_init and get_or_default#3316
bobzhang merged 2 commits intomainfrom
hongbo/sorted-map-api

Conversation

@bobzhang
Copy link
Contributor

@bobzhang bobzhang commented Mar 19, 2026

Summary

Add get_or_init and get_or_default to SortedMap, bringing it to API parity with HashMap which already has both methods.

  • get_or_init(key, init): Returns the existing value for key, or calls init() to produce a value, inserts it, and returns it.
  • get_or_default(key, default): Returns the existing value for key, or returns default without modifying the map.

Test plan

  • All 68 sorted_map tests pass
  • moon check passes

🤖 Generated with Claude Code


Open with Devin

Add missing API methods to bring SortedMap to parity with HashMap:
- get_or_init: returns existing value or inserts and returns init()
- get_or_default: returns existing value or returns default

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coveralls
Copy link
Collaborator

coveralls commented Mar 19, 2026

Pull Request Test Coverage Report for Build 3066

Details

  • 0 of 8 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.05%) to 95.716%

Changes Missing Coverage Covered Lines Changed/Added Lines %
sorted_map/map.mbt 0 8 0.0%
Totals Coverage Status
Change from base Build 3061: -0.05%
Covered Lines: 13762
Relevant Lines: 14378

💛 - Coveralls

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@bobzhang bobzhang merged commit 5db0298 into main Mar 19, 2026
14 checks passed
@bobzhang bobzhang deleted the hongbo/sorted-map-api branch March 19, 2026 23:41
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.

2 participants