-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
The current function get
attempts to find an exact key match; if it fails, it returns None
. I propose the addition of four variants:
get_lt
finds the greatest(key, element)
in the map/set that is less than the given key.get_lte
returns the lookup key and element in the map if present, otherwise returning the next smallest key and element.get_gt
finds the smallest(key, element)
in the map/set that is greater than the given key.get_gte
looks up the key; if present, returns it and the element, if not, returns the next largest key and element.
The specific use case that prompted this:
I'm working on a toy Smalltalk implementation. One of the implementation methods is "given an object pointer, find the next object pointer that is an instance of of the class." Given a value instances: BTreeSet<Pointer>
, the implementation is simply get_gt(obj_ptr)
.
JustAPerson, phil-opp, rgrig and vihdzp
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.