diff --git a/src/functions.php b/src/functions.php index 650b32e..5e56ae8 100644 --- a/src/functions.php +++ b/src/functions.php @@ -1,34 +1,42 @@ value pairs. - */ -function map(iterable $values = []): Map -{ - return new Map($values); +if (!function_exists('Ds\\map')) { + /** + * Create a new Map from an iterable of key => value pairs. + */ + function map(iterable $values = []): Map + { + return new Map($values); + } } -/** - * Create a new Set from an iterable. - */ -function set(iterable $values = []): Set -{ - return new Set($values); +if (!function_exists('Ds\\set')) { + /** + * Create a new Set from an iterable. + */ + function set(iterable $values = []): Set + { + return new Set($values); + } } -/** - * Create a new Heap from an iterable with optional comparator. - */ -function heap(iterable $values = [], ?callable $comparator = null): Heap -{ - return new Heap($values, $comparator); +if (!function_exists('Ds\\heap')) { + /** + * Create a new Heap from an iterable with optional comparator. + */ + function heap(iterable $values = [], ?callable $comparator = null): Heap + { + return new Heap($values, $comparator); + } }