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 adding an immutable tuple type #52

Closed
rtheunissen opened this issue Aug 31, 2016 · 1 comment

Comments

@rtheunissen
Copy link
Member

commented Aug 31, 2016

This would be an immutable, array access zval buffer which would serve as the groups in operations such as groupBy. Instead of a Map<mixed, Sequence> it would be Map<mixed, Tuple>. It would be very easy to convert those tuples into sequences if you need the extra mutability and functionality.

$map->groupBy('key')->apply('sequence'); // assuming sequence is a function

$map->groupBy('key')->apply(function($key, $value) {
    return new Sequence($value);
});

API I'm thinking of is basically:

  • __construct(iterable|array)
  • get(int)
  • toArray()
  • count()
  • clear() ??
  • isEmpty() ??

@rtheunissen rtheunissen added this to the 2.0.0 milestone Aug 31, 2016

@rtheunissen rtheunissen self-assigned this Aug 31, 2016

@rtheunissen

This comment has been minimized.

Copy link
Member Author

commented Sep 2, 2016

Have decided that this is a good idea. Will replace Pair and Vector, Deque becomes Sequence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.