Last active
December 16, 2015 16:49
-
-
Save mnapoli/5466043 to your computer and use it in GitHub Desktop.
Collection and Map interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* In this example, a collection is a map of values indexed by a key (numeric or string) | |
*/ | |
interface Collection extends Countable, IteratorAggregate, ArrayAccess | |
{ | |
function add($value); | |
function set($key, $value); | |
function get($key); | |
function contains($key); | |
function containsValue($value); | |
function remove($key); | |
function removeValue($value); | |
function clear(); | |
function count(); | |
function isEmpty(); | |
function filter(Closure $p); | |
function forAll(Closure $p); | |
function map(Closure $func); | |
function toArray(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* In this example, a Collection is a list of values (not indexed or mapped). | |
*/ | |
interface Collection extends Countable, IteratorAggregate, ArrayAccess | |
{ | |
function add($value); | |
function addAll(Collection $collection); | |
function contains($value); | |
function containsAll(Collection $collection); | |
function remove($value); | |
function removeAll(Collection $collection); | |
function clear(); | |
function count(); | |
function isEmpty(); | |
function filter(Closure $p); | |
function forAll(Closure $p); | |
function map(Closure $func); | |
function toArray(); | |
} | |
/** | |
* A map is a list of values indexed by a key | |
*/ | |
interface Map extends Countable, IteratorAggregate, ArrayAccess | |
{ | |
function set($key, $value); | |
function get($key); | |
function getKeys(); | |
function getValues(); | |
function contains($key); | |
function containsValue($value); | |
function remove($key); | |
function clear(); | |
function count(); | |
function isEmpty(); | |
function set($key, $value); | |
function filter(Closure $p); | |
function forAll(Closure $p); | |
function map(Closure $func); | |
function toArray(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment