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

Can expiringmap provide a function to obtain multiple keys? #86

Open
wp973 opened this issue Oct 25, 2023 · 0 comments
Open

Can expiringmap provide a function to obtain multiple keys? #86

wp973 opened this issue Oct 25, 2023 · 0 comments

Comments

@wp973
Copy link

wp973 commented Oct 25, 2023

like caffeine getAllPresent

 Map<K, V> getAllPresent(Iterable<? extends K> keys)

I tried to write a method, is this method feasible?🤔

  public List<V> getAllPresent(List<K> keys) {

    List<V> result = Collections.emptyList();

    if (keys != null && !keys.isEmpty()) {
      result = new ArrayList<V>(keys.size());

      for (K key : keys) {
        V value = get(key);

        if (value != null) {
          result.add(get(key));
        }
      }

    }

    return result;
  }

Thanks for your reply.

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

1 participant