PHP Класс Qaribou\Collection\ImmArray

Наследование: implements Iterato\Iterator, implements ArrayAcces\ArrayAccess, implements Countabl\Countable, implements JsonSerializabl\JsonSerializable
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
concat ( ) : ImmArray Concat to the end of this array
count ( ) Countable
current ( ) Iterator
filter ( callable $cb ) : ImmArray Filter out elements
fromArray ( array $arr ) : ImmArray Build from an array
fromItems ( Traversable $arr ) : ImmArray Factory for building ImmArrays from any traversable
join ( string $token = ',', string $secondToken = null ) : string Join a set of strings together.
jsonSerialize ( ) JsonSerializable
key ( )
map ( callable $cb ) : ImmArray Map elements to a new ImmArray via a callback
next ( )
offsetExists ( $offset ) ArrayAccess
offsetGet ( $offset )
offsetSet ( $offset, $value )
offsetUnset ( $offset )
reduce ( callable $cb, mixed $initial = null ) Reduce to a single value
rewind ( )
slice ( integer $begin, integer $end = null ) : ImmArray Take a slice of the array
sort ( callable $cb = null ) : ImmArray Return a new sorted ImmArray
sortHeap ( SplHeap $heap ) : ImmArray Sort a new ImmArray by filtering through a heap.
toArray ( )
valid ( )
walk ( callable $cb ) : ImmArray forEach, or "walk" the data Exists primarily to provide a consistent interface, though it's seldom any better than a simple php foreach. Mainly useful for chaining.

Защищенные методы

Метод Описание
arraySort ( callable $cb = null ) : ImmArray Fallback behaviour to use the builtin array sort functions
heapSort ( callable $cb ) : ImmArray Sort by applying a CallbackHeap and building a new heap Can be efficient for sorting large stored objects.
mergeSort ( callable $cb ) : ImmArray Perform a bottom-up, non-recursive, in-place mergesort.
quickSort ( callable $cb ) : ImmArray A classic quickSort - great for inplace sorting a big fixed array

Приватные методы

Метод Описание
__construct ( Traversable $immute ) Create an immutable array

Описание методов

arraySort() защищенный Метод

Fallback behaviour to use the builtin array sort functions
protected arraySort ( callable $cb = null ) : ImmArray
$cb callable The callback for comparison
Результат ImmArray

concat() публичный Метод

Concat to the end of this array
public concat ( ) : ImmArray
Результат ImmArray

count() публичный Метод

Countable
public count ( )

current() публичный Метод

Iterator
public current ( )

filter() публичный Метод

Filter out elements
public filter ( callable $cb ) : ImmArray
$cb callable Function to filter out on false
Результат ImmArray

fromArray() публичный статический Метод

Build from an array
public static fromArray ( array $arr ) : ImmArray
$arr array
Результат ImmArray

fromItems() публичный статический Метод

Factory for building ImmArrays from any traversable
public static fromItems ( Traversable $arr ) : ImmArray
$arr Traversable
Результат ImmArray

heapSort() защищенный Метод

Sort by applying a CallbackHeap and building a new heap Can be efficient for sorting large stored objects.
protected heapSort ( callable $cb ) : ImmArray
$cb callable The comparison callback
Результат ImmArray

join() публичный Метод

Join a set of strings together.
public join ( string $token = ',', string $secondToken = null ) : string
$token string Main token to put between elements
$secondToken string If set, $token on left $secondToken on right
Результат string

jsonSerialize() публичный Метод

JsonSerializable
public jsonSerialize ( )

key() публичный Метод

public key ( )

map() публичный Метод

Map elements to a new ImmArray via a callback
public map ( callable $cb ) : ImmArray
$cb callable Function to map new data
Результат ImmArray

mergeSort() защищенный Метод

Efficient for very-large objects, and written without recursion since PHP isn't well optimized for large recursion stacks.
protected mergeSort ( callable $cb ) : ImmArray
$cb callable The callback for comparison
Результат ImmArray

next() публичный Метод

public next ( )

offsetExists() публичный Метод

ArrayAccess
public offsetExists ( $offset )

offsetGet() публичный Метод

public offsetGet ( $offset )

offsetSet() публичный Метод

public offsetSet ( $offset, $value )

offsetUnset() публичный Метод

public offsetUnset ( $offset )

quickSort() защищенный Метод

A classic quickSort - great for inplace sorting a big fixed array
protected quickSort ( callable $cb ) : ImmArray
$cb callable The callback for comparison
Результат ImmArray

reduce() публичный Метод

Reduce to a single value
public reduce ( callable $cb, mixed $initial = null )
$cb callable Callback( mixed $previous, mixed $current[, mixed $index, mixed $immArray] ):mixed Callback to run reducing function
$initial mixed Initial value for first argument

rewind() публичный Метод

public rewind ( )

slice() публичный Метод

Take a slice of the array
public slice ( integer $begin, integer $end = null ) : ImmArray
$begin integer Start index of slice
$end integer End index of slice
Результат ImmArray

sort() публичный Метод

Return a new sorted ImmArray
public sort ( callable $cb = null ) : ImmArray
$cb callable The sort callback
Результат ImmArray

sortHeap() публичный Метод

Tends to run much faster than array or merge sorts, since you're only sorting the pointers, and the sort function is running in a highly optimized space.
public sortHeap ( SplHeap $heap ) : ImmArray
$heap SplHeap The heap to run for sorting
Результат ImmArray

toArray() публичный Метод

public toArray ( )

valid() публичный Метод

public valid ( )

walk() публичный Метод

Named walk for historic reasons - forEach is reserved in PHP
public walk ( callable $cb ) : ImmArray
$cb callable Function to call on each element
Результат ImmArray