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

Consider useful features #5

Open
ladvoc opened this issue Aug 30, 2024 · 1 comment
Open

Consider useful features #5

ladvoc opened this issue Aug 30, 2024 · 1 comment

Comments

@ladvoc
Copy link
Owner

ladvoc commented Aug 30, 2024

Given the unique characteristics of BijectiveDictionary, think about features that would be useful in general-purpose applications and consider which should be added. For example, the bimap crate in Rust (which implements a bijective dictionary) includes an insert method that informs the caller if any existing entry was overwritten during the insertion.

@DandyLyons
Copy link
Collaborator

Agreed. That functionality would be very useful. IdentifiedArray has something similar where it will inform you if the item was successfully inserted or not. It might be worth it to draw inspiration from this API, so that we don't have to reinvent the wheel. (Or there might be an example in the standard library or Swift Collections, that would be better to follow).

https://swiftpackageindex.com/pointfreeco/swift-identified-collections/main/documentation/identifiedcollections/identifiedarray/insert(_:at:)

Also, part of me would like to be able to declare at the call site, if it is okay to override. If I don't want it to override, and if the element already exists, then it will not insert, and it will let me know the result.

Something like bijectiveDictionary.insert(left: element, override: true)

@ladvoc ladvoc changed the title Consider Useful Features Consider useful features Sep 8, 2024
@DandyLyons DandyLyons added this to the BijectiveDictionary 1.0 milestone Sep 14, 2024
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

No branches or pull requests

2 participants