How about implementing more data structures (ie Map, Set)
| From: | Victor Berchet | Date: | Tue, 18 Dec 2012 14:43:20 +0000 |
| Subject: | How about implementing more data structures (ie Map, Set) | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-64342@lists.php.net to get a copy of this message | ||
Dear all:
I would like to get your feedback on implementing some more data structure in the PHP core.
Things like Set, Map could be really helpful.
A Set would be an unordered collection with no duplicate elements (same as in Python)
$setA = new Set();
$setA->append('a');
$setA->append('a');
$setB = new Set();
$setB->append('b');
$setA == $setB;
// A set can hold objects
$set->append($object);
A Map would be an associative array that can hold objects (same as Python dictionaries)
$map= new Map();
$map[$setA] = 'Hello, world!';
echo $maps[$setB]; // Hello, world !
I can not really help with the implementation, however I could help defining the API, creating a test suite and docs should this idea be accepted.
Note: I had to implement this in PHP while working on Automaton, it's tedious and inefficient.
Thanks for your feedback,
Victor