[Collection] use pure callables for filtering and mapping

This commit is contained in:
azjezz 2020-09-02 04:26:36 +01:00
parent 95e0cb37ad
commit 88f3d7edc0
12 changed files with 127 additions and 126 deletions

View File

@ -42,7 +42,7 @@ interface AccessibleCollectionInterface extends CollectionInterface, IndexAccess
* The keys associated with the current `AccessibleCollectionInterface` remain unchanged in the
* returned `AccessibleCollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* `AccessibleCollectionInterface` values
*
* @psalm-return AccessibleCollectionInterface<Tk, Tv> - a AccessibleCollectionInterface containing the values after a user-specified condition
@ -61,7 +61,7 @@ interface AccessibleCollectionInterface extends CollectionInterface, IndexAccess
* The keys associated with the current `AccessibleCollectionInterface` remain unchanged in the
* returned `AccessibleCollectionInterface`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* `AccessibleCollectionInterface` keys and values
*
* @psalm-return AccessibleCollectionInterface<Tk, Tv> - a `AccessibleCollectionInterface` containing the values after a user-specified
@ -82,7 +82,7 @@ interface AccessibleCollectionInterface extends CollectionInterface, IndexAccess
*
* @psalm-template Tu
*
* @psalm-param (callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* `AccessibleCollectionInterface` values
*
* @psalm-return AccessibleCollectionInterface<Tk, Tu> - a `AccessibleCollectionInterface` containing key/value pairs after a user-specified
@ -103,7 +103,7 @@ interface AccessibleCollectionInterface extends CollectionInterface, IndexAccess
*
* @psalm-template Tu
*
* @psalm-param (callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* `AccessibleCollectionInterface` keys and values
*
* @psalm-return AccessibleCollectionInterface<Tk, Tu> - a `AccessibleCollectionInterface` containing the values after a user-specified
@ -200,7 +200,7 @@ interface AccessibleCollectionInterface extends CollectionInterface, IndexAccess
* The returned `AccessibleCollectionInterface` will always be a proper subset of the current
* `AccessibleCollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(Tv): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return AccessibleCollectionInterface<Tk, Tv> - A `AccessibleCollectionInterface` that is a proper subset of the current
@ -234,7 +234,7 @@ interface AccessibleCollectionInterface extends CollectionInterface, IndexAccess
* The returned `AccessibleCollectionInterface` will always be a proper subset of the current
* `AccessibleCollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(Tv): bool) $fn - The callback used to determine the starting element for the
* returned `AccessibleCollectionInterface`.
*
* @psalm-return AccessibleCollectionInterface<Tk, Tv> - A `AccessibleCollectionInterface` that is a proper subset of the current

View File

@ -54,7 +54,7 @@ interface CollectionInterface extends Countable, IteratorAggregate, JsonSerializ
* The keys associated with the current `CollectionInterface` remain unchanged in the
* returned `CollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* `CollectionInterface` values
*
* @psalm-return CollectionInterface<Tk, Tv> - a CollectionInterface containing the values after a user-specified condition
@ -73,7 +73,7 @@ interface CollectionInterface extends Countable, IteratorAggregate, JsonSerializ
* The keys associated with the current `CollectionInterface` remain unchanged in the
* returned `CollectionInterface`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* `CollectionInterface` keys and values
*
* @psalm-return CollectionInterface<Tk, Tv> - a `CollectionInterface` containing the values after a user-specified
@ -94,7 +94,7 @@ interface CollectionInterface extends Countable, IteratorAggregate, JsonSerializ
*
* @psalm-template Tu
*
* @psalm-param (callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* `CollectionInterface` values
*
* @psalm-return CollectionInterface<Tk, Tu> - a `CollectionInterface` containing key/value pairs after a user-specified
@ -115,7 +115,7 @@ interface CollectionInterface extends Countable, IteratorAggregate, JsonSerializ
*
* @psalm-template Tu
*
* @psalm-param (callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* `CollectionInterface` keys and values
*
* @psalm-return CollectionInterface<Tk, Tu> - a `CollectionInterface` containing the values after a user-specified
@ -168,7 +168,7 @@ interface CollectionInterface extends Countable, IteratorAggregate, JsonSerializ
* The returned `CollectionInterface` will always be a proper subset of the current
* `CollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(Tv): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return CollectionInterface<Tk, Tv> - A `CollectionInterface` that is a proper subset of the current
@ -202,7 +202,7 @@ interface CollectionInterface extends Countable, IteratorAggregate, JsonSerializ
* The returned `CollectionInterface` will always be a proper subset of the current
* `CollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(Tv): bool) $fn - The callback used to determine the starting element for the
* returned `CollectionInterface`.
*
* @psalm-return CollectionInterface<Tk, Tv> - A `CollectionInterface` that is a proper subset of the current

View File

@ -7,6 +7,7 @@ namespace Psl\Collection;
use Psl;
use Psl\Arr;
use Psl\Iter;
use Psl\Type;
/**
* @template Tk of array-key
@ -30,7 +31,7 @@ final class Map implements MapInterface
*/
public function __construct(iterable $elements)
{
$this->elements = Iter\to_array_with_keys($elements);
$this->elements = Type\is_array($elements) ? $elements : iterator_to_array($elements);
}
/**
@ -41,18 +42,18 @@ final class Map implements MapInterface
*/
public function first()
{
return Iter\first($this->elements);
return Arr\first($this->elements);
}
/**
* Returns the first key in the current collection.
*
* @psalm-return Tk|null - The first key in the current collection, or `null` if the
* current collection is empty
* current collection is empty.
*/
public function firstKey()
{
return Iter\first_key($this->elements);
return Arr\first_key($this->elements);
}
/**
@ -63,18 +64,18 @@ final class Map implements MapInterface
*/
public function last()
{
return Iter\last($this->elements);
return Arr\last($this->elements);
}
/**
* Returns the last key in the current collection.
*
* @psalm-return Tk|null - The last key in the current collection, or `null` if the
* current collection is empty
* current collection is empty.
*/
public function lastKey()
{
return Iter\last_key($this->elements);
return Arr\last_key($this->elements);
}
/**
@ -121,7 +122,7 @@ final class Map implements MapInterface
*/
public function count(): int
{
return Iter\count($this->elements);
return Arr\count($this->elements);
}
/**
@ -165,7 +166,7 @@ final class Map implements MapInterface
*/
public function contains($k): bool
{
return Iter\contains_key($this->elements, $k);
return Arr\contains_key($this->elements, $k);
}
/**
@ -189,7 +190,7 @@ final class Map implements MapInterface
*/
public function values(): Vector
{
return new Vector(Iter\values($this->elements));
return new Vector(Arr\values($this->elements));
}
/**
@ -212,7 +213,7 @@ final class Map implements MapInterface
* The keys associated with the current `Map` remain unchanged in the
* returned `Map`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* `Map` values
*
* @psalm-return Map<Tk, Tv> - a Map containing the values after a user-specified condition
@ -220,7 +221,7 @@ final class Map implements MapInterface
*/
public function filter(callable $fn): Map
{
return new Map(Iter\filter($this->elements, $fn));
return new Map(Arr\filter($this->elements, $fn));
}
/**
@ -234,7 +235,7 @@ final class Map implements MapInterface
* The keys associated with the current `Map` remain unchanged in the
* returned `Map`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* `Map` keys and values
*
* @psalm-return Map<Tk, Tv> - a `Map` containing the values after a user-specified
@ -243,7 +244,7 @@ final class Map implements MapInterface
*/
public function filterWithKey(callable $fn): Map
{
return new Map(Iter\filter_with_key($this->elements, $fn));
return new Map(Arr\filter_with_key($this->elements, $fn));
}
/**
@ -258,7 +259,7 @@ final class Map implements MapInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* `Map` values
*
* @psalm-return Map<Tk, Tu> - a `Map` containing key/value pairs after a user-specified
@ -282,7 +283,7 @@ final class Map implements MapInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* `Map` keys and values
*
* @psalm-return Map<Tk, Tu> - a `Map` containing the values after a user-specified
@ -351,7 +352,7 @@ final class Map implements MapInterface
*/
public function take(int $n): Map
{
return new Map(Iter\take($this->elements, $n));
return new Map(Arr\take($this->elements, $n));
}
/**
@ -362,7 +363,7 @@ final class Map implements MapInterface
* The returned `Map` will always be a proper subset of the current
* `Map`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(Tv): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return Map<Tk, Tv> - A `Map` that is a proper subset of the current
@ -370,7 +371,7 @@ final class Map implements MapInterface
*/
public function takeWhile(callable $fn): Map
{
return new Map(Iter\take_while($this->elements, $fn));
return new Map(Arr\take_while($this->elements, $fn));
}
/**
@ -392,7 +393,7 @@ final class Map implements MapInterface
*/
public function drop(int $n): Map
{
return new Map(Iter\drop($this->elements, $n));
return new Map(Arr\drop($this->elements, $n));
}
/**
@ -403,7 +404,7 @@ final class Map implements MapInterface
* The returned `Map` will always be a proper subset of the current
* `Map`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(Tv): bool) $fn - The callback used to determine the starting element for the
* returned `Map`.
*
* @psalm-return Map<Tk, Tv> - A `Map` that is a proper subset of the current
@ -411,7 +412,7 @@ final class Map implements MapInterface
*/
public function dropWhile(callable $fn): Map
{
return new Map(Iter\drop_while($this->elements, $fn));
return new Map(Arr\drop_while($this->elements, $fn));
}
/**
@ -437,6 +438,6 @@ final class Map implements MapInterface
*/
public function slice(int $start, int $len): Map
{
return new Map(Iter\slice($this->elements, $start, $len));
return new Map(Arr\slice($this->elements, $start, $len));
}
}

View File

@ -37,7 +37,7 @@ interface MapInterface extends AccessibleCollectionInterface
* The keys associated with the current `MapInterface` remain unchanged in the
* returned `MapInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* `MapInterface` values
*
* @psalm-return MapInterface<Tk, Tv> - a MapInterface containing the values after a user-specified condition
@ -56,7 +56,7 @@ interface MapInterface extends AccessibleCollectionInterface
* The keys associated with the current `MapInterface` remain unchanged in the
* returned `MapInterface`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* `MapInterface` keys and values
*
* @psalm-return MapInterface<Tk, Tv> - a `MapInterface` containing the values after a user-specified
@ -77,7 +77,7 @@ interface MapInterface extends AccessibleCollectionInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* `MapInterface` values
*
* @psalm-return MapInterface<Tk, Tu> - a `MapInterface` containing key/value pairs after a user-specified
@ -98,7 +98,7 @@ interface MapInterface extends AccessibleCollectionInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* `MapInterface` keys and values
*
* @psalm-return MapInterface<Tk, Tu> - a `MapInterface` containing the values after a user-specified
@ -195,7 +195,7 @@ interface MapInterface extends AccessibleCollectionInterface
* The returned `MapInterface` will always be a proper subset of the current
* `MapInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(Tv): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return MapInterface<Tk, Tv> - A `MapInterface` that is a proper subset of the current
@ -229,7 +229,7 @@ interface MapInterface extends AccessibleCollectionInterface
* The returned `MapInterface` will always be a proper subset of the current
* `MapInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(Tv): bool) $fn - The callback used to determine the starting element for the
* returned `MapInterface`.
*
* @psalm-return MapInterface<Tk, Tv> - A `MapInterface` that is a proper subset of the current

View File

@ -44,7 +44,7 @@ interface MutableAccessibleCollectionInterface extends AccessibleCollectionInter
* The keys associated with the current `MutableAccessibleCollectionInterface` remain unchanged in the
* returned `MutableAccessibleCollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* `MutableAccessibleCollectionInterface` values
*
* @psalm-return MutableAccessibleCollectionInterface<Tk, Tv> - a Collection containing the values after a user-specified condition
@ -63,7 +63,7 @@ interface MutableAccessibleCollectionInterface extends AccessibleCollectionInter
* The keys associated with the current `MutableAccessibleCollectionInterface` remain unchanged in the
* returned `MutableAccessibleCollectionInterface`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* `MutableAccessibleCollectionInterface` keys and values
*
* @psalm-return MutableAccessibleCollectionInterface<Tk, Tv> - a `MutableAccessibleCollectionInterface` containing the values after a user-specified
@ -84,7 +84,7 @@ interface MutableAccessibleCollectionInterface extends AccessibleCollectionInter
*
* @psalm-template Tu
*
* @psalm-param (callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* `MutableAccessibleCollectionInterface` values
*
* @psalm-return MutableAccessibleCollectionInterface<Tk, Tu> - a `MutableAccessibleCollectionInterface` containing key/value pairs after a user-specified
@ -105,7 +105,7 @@ interface MutableAccessibleCollectionInterface extends AccessibleCollectionInter
*
* @psalm-template Tu
*
* @psalm-param (callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* `MutableAccessibleCollectionInterface` keys and values
*
* @psalm-return MutableAccessibleCollectionInterface<Tk, Tu> - a `MutableAccessibleCollectionInterface` containing the values after a user-specified
@ -215,7 +215,7 @@ interface MutableAccessibleCollectionInterface extends AccessibleCollectionInter
* The returned `MutableAccessibleCollectionInterface` will always be a proper subset of the current
* `MutableAccessibleCollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(Tv): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return MutableAccessibleCollectionInterface<Tk, Tv> - A `MutableAccessibleCollectionInterface` that is a proper subset of the current
@ -249,7 +249,7 @@ interface MutableAccessibleCollectionInterface extends AccessibleCollectionInter
* The returned `MutableAccessibleCollectionInterface` will always be a proper subset of the current
* `MutableAccessibleCollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(Tv): bool) $fn - The callback used to determine the starting element for the
* returned `MutableAccessibleCollectionInterface`.
*
* @psalm-return MutableAccessibleCollectionInterface<Tk, Tv> - A `MutableAccessibleCollectionInterface` that is a proper subset of the current

View File

@ -29,7 +29,7 @@ interface MutableCollectionInterface extends CollectionInterface
* The keys associated with the current `MutableCollectionInterface` remain unchanged in the
* returned `MutableCollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* `MutableCollectionInterface` values
*
* @psalm-return MutableCollectionInterface<Tk, Tv> - a Collection containing the values after a user-specified condition
@ -48,7 +48,7 @@ interface MutableCollectionInterface extends CollectionInterface
* The keys associated with the current `MutableCollectionInterface` remain unchanged in the
* returned `MutableCollectionInterface`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* `MutableCollectionInterface` keys and values
*
* @psalm-return MutableCollectionInterface<Tk, Tv> - a `MutableCollectionInterface` containing the values after a user-specified
@ -69,7 +69,7 @@ interface MutableCollectionInterface extends CollectionInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* `MutableCollectionInterface` values
*
* @psalm-return MutableCollectionInterface<Tk, Tu> - a `MutableCollectionInterface` containing key/value pairs after a user-specified
@ -90,7 +90,7 @@ interface MutableCollectionInterface extends CollectionInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* `MutableCollectionInterface` keys and values
*
* @psalm-return MutableCollectionInterface<Tk, Tu> - a `MutableCollectionInterface` containing the values after a user-specified
@ -143,7 +143,7 @@ interface MutableCollectionInterface extends CollectionInterface
* The returned `MutableCollectionInterface` will always be a proper subset of the current
* `MutableCollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(Tv): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return MutableCollectionInterface<Tk, Tv> - A `MutableCollectionInterface` that is a proper subset of the current
@ -177,7 +177,7 @@ interface MutableCollectionInterface extends CollectionInterface
* The returned `MutableCollectionInterface` will always be a proper subset of the current
* `MutableCollectionInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(Tv): bool) $fn - The callback used to determine the starting element for the
* returned `MutableCollectionInterface`.
*
* @psalm-return MutableCollectionInterface<Tk, Tv> - A `MutableCollectionInterface` that is a proper subset of the current

View File

@ -39,7 +39,7 @@ final class MutableMap implements MutableMapInterface
*/
public function first()
{
return Iter\first($this->elements);
return Arr\first($this->elements);
}
/**
@ -50,7 +50,7 @@ final class MutableMap implements MutableMapInterface
*/
public function firstKey()
{
return Iter\first_key($this->elements);
return Arr\first_key($this->elements);
}
/**
@ -61,7 +61,7 @@ final class MutableMap implements MutableMapInterface
*/
public function last()
{
return Iter\last($this->elements);
return Arr\last($this->elements);
}
/**
@ -72,7 +72,7 @@ final class MutableMap implements MutableMapInterface
*/
public function lastKey()
{
return Iter\last_key($this->elements);
return Arr\last_key($this->elements);
}
/**
@ -119,7 +119,7 @@ final class MutableMap implements MutableMapInterface
*/
public function count(): int
{
return Iter\count($this->elements);
return Arr\count($this->elements);
}
/**
@ -163,7 +163,7 @@ final class MutableMap implements MutableMapInterface
*/
public function contains($k): bool
{
return Iter\contains_key($this->elements, $k);
return Arr\contains_key($this->elements, $k);
}
/**
@ -186,7 +186,7 @@ final class MutableMap implements MutableMapInterface
*/
public function values(): MutableVector
{
return new MutableVector(Iter\values($this->elements));
return new MutableVector(Arr\values($this->elements));
}
/**
@ -196,7 +196,7 @@ final class MutableMap implements MutableMapInterface
*/
public function keys(): MutableVector
{
return new MutableVector(Iter\keys($this->elements));
return new MutableVector(Arr\keys($this->elements));
}
/**
@ -209,7 +209,7 @@ final class MutableMap implements MutableMapInterface
* The keys associated with the current `MutableMap` remain unchanged in the
* returned `MutableMap`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* `MutableMap` values
*
* @psalm-return MutableMap<Tk, Tv> - a MutableMap containing the values after a user-specified condition
@ -217,7 +217,7 @@ final class MutableMap implements MutableMapInterface
*/
public function filter(callable $fn): MutableMap
{
return new MutableMap(Iter\filter($this->elements, $fn));
return new MutableMap(Arr\filter($this->elements, $fn));
}
/**
@ -231,7 +231,7 @@ final class MutableMap implements MutableMapInterface
* The keys associated with the current `MutableMap` remain unchanged in the
* returned `MutableMap`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* `MutableMap` keys and values
*
* @psalm-return MutableMap<Tk, Tv> - a `MutableMap` containing the values after a user-specified
@ -240,7 +240,7 @@ final class MutableMap implements MutableMapInterface
*/
public function filterWithKey(callable $fn): MutableMap
{
return new MutableMap(Iter\filter_with_key($this->elements, $fn));
return new MutableMap(Arr\filter_with_key($this->elements, $fn));
}
/**
@ -255,7 +255,7 @@ final class MutableMap implements MutableMapInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* `MutableMap` values
*
* @psalm-return MutableMap<Tk, Tu> - a `MutableMap` containing key/value pairs after a user-specified
@ -279,7 +279,7 @@ final class MutableMap implements MutableMapInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* `MutableMap` keys and values
*
* @psalm-return MutableMap<Tk, Tu> - a `MutableMap` containing the values after a user-specified
@ -348,7 +348,7 @@ final class MutableMap implements MutableMapInterface
*/
public function take(int $n): MutableMap
{
return new MutableMap(Iter\take($this->elements, $n));
return new MutableMap(Arr\take($this->elements, $n));
}
/**
@ -359,7 +359,7 @@ final class MutableMap implements MutableMapInterface
* The returned `MutableMap` will always be a proper subset of the current
* `MutableMap`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(Tv): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return MutableMap<Tk, Tv> - A `MutableMap` that is a proper subset of the current
@ -367,7 +367,7 @@ final class MutableMap implements MutableMapInterface
*/
public function takeWhile(callable $fn): MutableMap
{
return new MutableMap(Iter\take_while($this->elements, $fn));
return new MutableMap(Arr\take_while($this->elements, $fn));
}
/**
@ -390,7 +390,7 @@ final class MutableMap implements MutableMapInterface
*/
public function drop(int $n): MutableMap
{
return new MutableMap(Iter\drop($this->elements, $n));
return new MutableMap(Arr\drop($this->elements, $n));
}
/**
@ -401,7 +401,7 @@ final class MutableMap implements MutableMapInterface
* The returned `MutableMap` will always be a proper subset of the current
* `MutableMap`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(Tv): bool) $fn - The callback used to determine the starting element for the
* returned `MutableMap`.
*
* @psalm-return MutableMap<Tk, Tv> - A `MutableMap` that is a proper subset of the current
@ -409,7 +409,7 @@ final class MutableMap implements MutableMapInterface
*/
public function dropWhile(callable $fn): MutableMap
{
return new MutableMap(Iter\drop_while($this->elements, $fn));
return new MutableMap(Arr\drop_while($this->elements, $fn));
}
/**
@ -435,7 +435,7 @@ final class MutableMap implements MutableMapInterface
*/
public function slice(int $start, int $len): MutableMap
{
return new MutableMap(Iter\slice($this->elements, $start, $len));
return new MutableMap(Arr\slice($this->elements, $start, $len));
}
/**

View File

@ -38,7 +38,7 @@ interface MutableMapInterface extends MapInterface, MutableAccessibleCollectionI
* The keys associated with the current `MutableMapInterface` remain unchanged in the
* returned `MutableMapInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tv): bool) $fn - The callback containing the condition to apply to the current
* `MutableMapInterface` values
*
* @psalm-return MutableMapInterface<Tk, Tv> - a MutableMapInterface containing the values after a user-specified condition
@ -57,7 +57,7 @@ interface MutableMapInterface extends MapInterface, MutableAccessibleCollectionI
* The keys associated with the current `MutableMapInterface` remain unchanged in the
* returned `MutableMapInterface`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(Tk, Tv): bool) $fn - The callback containing the condition to apply to the current
* `MutableMapInterface` keys and values
*
* @psalm-return MutableMapInterface<Tk, Tv> - a `MutableMapInterface` containing the values after a user-specified
@ -78,7 +78,7 @@ interface MutableMapInterface extends MapInterface, MutableAccessibleCollectionI
*
* @psalm-template Tu
*
* @psalm-param (callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tv): Tu) $fn - The callback containing the operation to apply to the current
* `MutableMapInterface` values
*
* @psalm-return MutableMapInterface<Tk, Tu> - a `MutableMapInterface` containing key/value pairs after a user-specified
@ -99,7 +99,7 @@ interface MutableMapInterface extends MapInterface, MutableAccessibleCollectionI
*
* @psalm-template Tu
*
* @psalm-param (callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(Tk, Tv): Tu) $fn - The callback containing the operation to apply to the current
* `MutableMapInterface` keys and values
*
* @psalm-return MutableMapInterface<Tk, Tu> - a `MutableMapInterface` containing the values after a user-specified
@ -196,7 +196,7 @@ interface MutableMapInterface extends MapInterface, MutableAccessibleCollectionI
* The returned `MutableMapInterface` will always be a proper subset of the current
* `MutableMapInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(Tv): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return MutableMapInterface<Tk, Tv> - A `MutableMapInterface` that is a proper subset of the current
@ -230,7 +230,7 @@ interface MutableMapInterface extends MapInterface, MutableAccessibleCollectionI
* The returned `MutableMapInterface` will always be a proper subset of the current
* `MutableMapInterface`.
*
* @psalm-param (callable(Tv): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(Tv): bool) $fn - The callback used to determine the starting element for the
* returned `MutableMapInterface`.
*
* @psalm-return MutableMapInterface<Tk, Tv> - A `MutableMapInterface` that is a proper subset of the current

View File

@ -40,7 +40,7 @@ final class MutableVector implements MutableVectorInterface
*/
public function first()
{
return Iter\first($this->elements);
return Arr\first($this->elements);
}
/**
@ -51,7 +51,7 @@ final class MutableVector implements MutableVectorInterface
*/
public function last()
{
return Iter\last($this->elements);
return Arr\last($this->elements);
}
/**
@ -77,7 +77,7 @@ final class MutableVector implements MutableVectorInterface
*/
public function count(): int
{
return Iter\count($this->elements);
return Arr\count($this->elements);
}
/**
@ -121,7 +121,7 @@ final class MutableVector implements MutableVectorInterface
*/
public function contains($k): bool
{
return Iter\contains_key($this->elements, $k);
return Arr\contains_key($this->elements, $k);
}
/**
@ -335,7 +335,7 @@ final class MutableVector implements MutableVectorInterface
* The keys associated with the current `MutableVector` remain unchanged in the
* returned `MutableVector`.
*
* @psalm-param (callable(T): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(T): bool) $fn - The callback containing the condition to apply to the current
* `MutableVector` values
*
* @psalm-return MutableVector<T> - a MutableVector containing the values after a user-specified condition
@ -343,7 +343,7 @@ final class MutableVector implements MutableVectorInterface
*/
public function filter(callable $fn): MutableVector
{
return new MutableVector(Iter\filter($this->elements, $fn));
return new MutableVector(Arr\filter($this->elements, $fn));
}
/**
@ -357,7 +357,7 @@ final class MutableVector implements MutableVectorInterface
* The keys associated with the current `MutableVector` remain unchanged in the
* returned `MutableVector`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(int, T): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(int, T): bool) $fn - The callback containing the condition to apply to the current
* `MutableVector` keys and values
*
* @psalm-return MutableVector<T> - a `MutableVector` containing the values after a user-specified
@ -366,7 +366,7 @@ final class MutableVector implements MutableVectorInterface
*/
public function filterWithKey(callable $fn): MutableVector
{
return new MutableVector(Iter\filter_with_key($this->elements, $fn));
return new MutableVector(Arr\filter_with_key($this->elements, $fn));
}
/**
@ -381,7 +381,7 @@ final class MutableVector implements MutableVectorInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(T): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(T): Tu) $fn - The callback containing the operation to apply to the current
* `MutableVector` values
*
* @psalm-return MutableVector<Tu> - a `MutableVector` containing key/value pairs after a user-specified
@ -405,7 +405,7 @@ final class MutableVector implements MutableVectorInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(int, T): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(int, T): Tu) $fn - The callback containing the operation to apply to the current
* `MutableVector` keys and values
*
* @psalm-return MutableVector<Tu> - a `MutableVector` containing the values after a user-specified
@ -470,7 +470,7 @@ final class MutableVector implements MutableVectorInterface
*/
public function take(int $n): MutableVector
{
return new MutableVector(Iter\take($this->elements, $n));
return new MutableVector(Arr\take($this->elements, $n));
}
/**
@ -481,7 +481,7 @@ final class MutableVector implements MutableVectorInterface
* The returned `MutableVector` will always be a proper subset of the current
* `MutableVector`.
*
* @psalm-param (callable(T): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(T): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return MutableVector<T> - A `MutableVector` that is a proper subset of the current
@ -489,7 +489,7 @@ final class MutableVector implements MutableVectorInterface
*/
public function takeWhile(callable $fn): MutableVector
{
return new MutableVector(Iter\take_while($this->elements, $fn));
return new MutableVector(Arr\take_while($this->elements, $fn));
}
/**
@ -512,7 +512,7 @@ final class MutableVector implements MutableVectorInterface
*/
public function drop(int $n): MutableVector
{
return new MutableVector(Iter\drop($this->elements, $n));
return new MutableVector(Arr\drop($this->elements, $n));
}
/**
@ -523,7 +523,7 @@ final class MutableVector implements MutableVectorInterface
* The returned `MutableVector` will always be a proper subset of the current
* `MutableVector`.
*
* @psalm-param (callable(T): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(T): bool) $fn - The callback used to determine the starting element for the
* returned `MutableVector`.
*
* @psalm-return MutableVector<T> - A `MutableVector` that is a proper subset of the current
@ -531,7 +531,7 @@ final class MutableVector implements MutableVectorInterface
*/
public function dropWhile(callable $fn): MutableVector
{
return new MutableVector(Iter\drop_while($this->elements, $fn));
return new MutableVector(Arr\drop_while($this->elements, $fn));
}
/**
@ -557,6 +557,6 @@ final class MutableVector implements MutableVectorInterface
*/
public function slice(int $start, int $len): MutableVector
{
return new MutableVector(Iter\slice($this->elements, $start, $len));
return new MutableVector(Arr\slice($this->elements, $start, $len));
}
}

View File

@ -44,7 +44,7 @@ interface MutableVectorInterface extends VectorInterface, MutableAccessibleColle
* The keys associated with the current `MutableVectorInterface` remain unchanged in the
* returned `MutableVectorInterface`.
*
* @psalm-param (callable(T): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(T): bool) $fn - The callback containing the condition to apply to the current
* `MutableVectorInterface` values
*
* @psalm-return MutableVectorInterface<T> - a MutableVectorInterface containing the values after a user-specified condition
@ -63,7 +63,7 @@ interface MutableVectorInterface extends VectorInterface, MutableAccessibleColle
* The keys associated with the current `MutableVectorInterface` remain unchanged in the
* returned `MutableVectorInterface`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(int, T): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(int, T): bool) $fn - The callback containing the condition to apply to the current
* `MutableVectorInterface` keys and values
*
* @psalm-return MutableVectorInterface<T> - a `MutableVectorInterface` containing the values after a user-specified
@ -84,7 +84,7 @@ interface MutableVectorInterface extends VectorInterface, MutableAccessibleColle
*
* @psalm-template Tu
*
* @psalm-param (callable(T): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(T): Tu) $fn - The callback containing the operation to apply to the current
* `MutableVectorInterface` values
*
* @psalm-return MutableVectorInterface<Tu> - a `MutableVectorInterface` containing key/value pairs after a user-specified
@ -105,7 +105,7 @@ interface MutableVectorInterface extends VectorInterface, MutableAccessibleColle
*
* @psalm-template Tu
*
* @psalm-param (callable(int, T): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(int, T): Tu) $fn - The callback containing the operation to apply to the current
* `MutableVectorInterface` keys and values
*
* @psalm-return MutableVectorInterface<Tu> - a `MutableVectorInterface` containing the values after a user-specified
@ -202,7 +202,7 @@ interface MutableVectorInterface extends VectorInterface, MutableAccessibleColle
* The returned `MutableVectorInterface` will always be a proper subset of the current
* `MutableVectorInterface`.
*
* @psalm-param (callable(T): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(T): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return MutableVectorInterface<T> - A `MutableVectorInterface` that is a proper subset of the current
@ -236,7 +236,7 @@ interface MutableVectorInterface extends VectorInterface, MutableAccessibleColle
* The returned `MutableVectorInterface` will always be a proper subset of the current
* `MutableVectorInterface`.
*
* @psalm-param (callable(T): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(T): bool) $fn - The callback used to determine the starting element for the
* returned `MutableVectorInterface`.
*
* @psalm-return MutableVectorInterface<T> - A `MutableVectorInterface` that is a proper subset of the current

View File

@ -42,7 +42,7 @@ final class Vector implements VectorInterface
*/
public function first()
{
return Iter\first($this->elements);
return Arr\first($this->elements);
}
/**
@ -53,7 +53,7 @@ final class Vector implements VectorInterface
*/
public function last()
{
return Iter\last($this->elements);
return Arr\last($this->elements);
}
/**
@ -79,7 +79,7 @@ final class Vector implements VectorInterface
*/
public function count(): int
{
return Iter\count($this->elements);
return Arr\count($this->elements);
}
/**
@ -124,7 +124,7 @@ final class Vector implements VectorInterface
*/
public function contains($k): bool
{
return Iter\contains_key($this->elements, $k);
return Arr\contains_key($this->elements, $k);
}
/**
@ -219,7 +219,7 @@ final class Vector implements VectorInterface
* The keys associated with the current `Vector` remain unchanged in the
* returned `Vector`.
*
* @psalm-param (callable(T): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(T): bool) $fn - The callback containing the condition to apply to the current
* `Vector` values
*
* @psalm-return Vector<T> - a Vector containing the values after a user-specified condition
@ -227,7 +227,7 @@ final class Vector implements VectorInterface
*/
public function filter(callable $fn): Vector
{
return new Vector(Iter\filter($this->elements, $fn));
return new Vector(Arr\filter($this->elements, $fn));
}
/**
@ -241,7 +241,7 @@ final class Vector implements VectorInterface
* The keys associated with the current `Vector` remain unchanged in the
* returned `Vector`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(int, T): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(int, T): bool) $fn - The callback containing the condition to apply to the current
* `Vector` keys and values
*
* @psalm-return Vector<T> - a `Vector` containing the values after a user-specified
@ -250,7 +250,7 @@ final class Vector implements VectorInterface
*/
public function filterWithKey(callable $fn): Vector
{
return new Vector(Iter\filter_with_key($this->elements, $fn));
return new Vector(Arr\filter_with_key($this->elements, $fn));
}
/**
@ -265,7 +265,7 @@ final class Vector implements VectorInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(T): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(T): Tu) $fn - The callback containing the operation to apply to the current
* `Vector` values
*
* @psalm-return Vector<Tu> - a `Vector` containing key/value pairs after a user-specified
@ -289,7 +289,7 @@ final class Vector implements VectorInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(int, T): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(int, T): Tu) $fn - The callback containing the operation to apply to the current
* `Vector` keys and values
*
* @psalm-return Vector<Tu> - a `Vector` containing the values after a user-specified
@ -354,7 +354,7 @@ final class Vector implements VectorInterface
*/
public function take(int $n): Vector
{
return new Vector(Iter\take($this->elements, $n));
return new Vector(Arr\take($this->elements, $n));
}
/**
@ -365,7 +365,7 @@ final class Vector implements VectorInterface
* The returned `Vector` will always be a proper subset of the current
* `Vector`.
*
* @psalm-param (callable(T): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(T): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return Vector<T> - A `Vector` that is a proper subset of the current
@ -373,7 +373,7 @@ final class Vector implements VectorInterface
*/
public function takeWhile(callable $fn): Vector
{
return new Vector(Iter\take_while($this->elements, $fn));
return new Vector(Arr\take_while($this->elements, $fn));
}
/**
@ -396,7 +396,7 @@ final class Vector implements VectorInterface
*/
public function drop(int $n): Vector
{
return new Vector(Iter\drop($this->elements, $n));
return new Vector(Arr\drop($this->elements, $n));
}
/**
@ -407,7 +407,7 @@ final class Vector implements VectorInterface
* The returned `Vector` will always be a proper subset of the current
* `Vector`.
*
* @psalm-param (callable(T): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(T): bool) $fn - The callback used to determine the starting element for the
* returned `Vector`.
*
* @psalm-return Vector<T> - A `Vector` that is a proper subset of the current
@ -415,7 +415,7 @@ final class Vector implements VectorInterface
*/
public function dropWhile(callable $fn): Vector
{
return new Vector(Iter\drop_while($this->elements, $fn));
return new Vector(Arr\drop_while($this->elements, $fn));
}
/**
@ -441,6 +441,6 @@ final class Vector implements VectorInterface
*/
public function slice(int $start, int $len): Vector
{
return new Vector(Iter\slice($this->elements, $start, $len));
return new Vector(Arr\slice($this->elements, $start, $len));
}
}

View File

@ -68,7 +68,7 @@ interface VectorInterface extends AccessibleCollectionInterface
* The keys associated with the current `VectorInterface` remain unchanged in the
* returned `VectorInterface`.
*
* @psalm-param (callable(T): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(T): bool) $fn - The callback containing the condition to apply to the current
* `VectorInterface` values
*
* @psalm-return VectorInterface<T> - a VectorInterface containing the values after a user-specified condition
@ -87,7 +87,7 @@ interface VectorInterface extends AccessibleCollectionInterface
* The keys associated with the current `VectorInterface` remain unchanged in the
* returned `VectorInterface`; the keys will be used in the filtering process only.
*
* @psalm-param (callable(int, T): bool) $fn - The callback containing the condition to apply to the current
* @psalm-param (pure-callable(int, T): bool) $fn - The callback containing the condition to apply to the current
* `VectorInterface` keys and values
*
* @psalm-return VectorInterface<T> - a `VectorInterface` containing the values after a user-specified
@ -108,7 +108,7 @@ interface VectorInterface extends AccessibleCollectionInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(T): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(T): Tu) $fn - The callback containing the operation to apply to the current
* `VectorInterface` values
*
* @psalm-return VectorInterface<Tu> - a `VectorInterface` containing key/value pairs after a user-specified
@ -129,7 +129,7 @@ interface VectorInterface extends AccessibleCollectionInterface
*
* @psalm-template Tu
*
* @psalm-param (callable(int, T): Tu) $fn - The callback containing the operation to apply to the current
* @psalm-param (pure-callable(int, T): Tu) $fn - The callback containing the operation to apply to the current
* `VectorInterface` keys and values
*
* @psalm-return VectorInterface<Tu> - a `VectorInterface` containing the values after a user-specified
@ -226,7 +226,7 @@ interface VectorInterface extends AccessibleCollectionInterface
* The returned `VectorInterface` will always be a proper subset of the current
* `VectorInterface`.
*
* @psalm-param (callable(T): bool) $fn - The callback that is used to determine the stopping
* @psalm-param (pure-callable(T): bool) $fn - The callback that is used to determine the stopping
* condition.
*
* @psalm-return VectorInterface<T> - A `VectorInterface` that is a proper subset of the current
@ -260,7 +260,7 @@ interface VectorInterface extends AccessibleCollectionInterface
* The returned `VectorInterface` will always be a proper subset of the current
* `VectorInterface`.
*
* @psalm-param (callable(T): bool) $fn - The callback used to determine the starting element for the
* @psalm-param (pure-callable(T): bool) $fn - The callback used to determine the starting element for the
* returned `VectorInterface`.
*
* @psalm-return VectorInterface<T> - A `VectorInterface` that is a proper subset of the current