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

Map type #226

Open
dmfs opened this issue Aug 19, 2019 · 2 comments
Open

Map type #226

dmfs opened this issue Aug 19, 2019 · 2 comments

Comments

@dmfs
Copy link
Owner

dmfs commented Aug 19, 2019

A simple immutable map type. Interface is tbd.

@dmfs
Copy link
Owner Author

dmfs commented Aug 20, 2019

Initial idea for the interface design:

public interface Map<Key, Value> extends Function<Key, Optional<Value>>, Set<Key>, Iterable<Pair<Key, Value>> {
    // returns the number of key value pairs in this map
    public int size();
}

@dmfs
Copy link
Owner Author

dmfs commented Aug 20, 2019

On a second though, we probably don't need the Set interface:

public interface Map<Key, Value> extends Function<Key, Optional<Value>>, Iterable<Pair<Key, Value>> {
    // returns the number of key value pairs in this map
    public int size();
}

If a Set is needed, it could be created like so:

Set<Key> keySet = new KeySet<>(map);

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