1 | <?php |
||
10 | abstract class AbstractList extends AbstractCollection { |
||
11 | |||
12 | /** |
||
13 | * Iterative reduction of this collection with the help of a callback function. The callback |
||
14 | * function takes two parameters, the first is the carry, the second the current item, with this |
||
15 | * signature: mixed callback(mixed $carry, mixed $item) |
||
16 | * |
||
17 | * @param callable $callback the callback function |
||
18 | * @param mixed $fallback the default value, that will be returned when the list is empty |
||
19 | * @return mixed |
||
20 | */ |
||
21 | public function reduce(callable $callback, $fallback = null) { |
||
24 | |||
25 | /** |
||
26 | * Sorts the collection. |
||
27 | * |
||
28 | * @param Comparator|callable $cmp |
||
29 | * @return $this |
||
30 | */ |
||
31 | public function sort($cmp = null) { |
||
36 | |||
37 | /** |
||
38 | * Reverses the order of all elements |
||
39 | * |
||
40 | * @return $this |
||
41 | */ |
||
42 | public function reverse() { |
||
46 | |||
47 | /** |
||
48 | * Sorts the collection in reverse order |
||
49 | * |
||
50 | * @see #sort |
||
51 | * @see #reverse |
||
52 | * @param Comparator|callable $cmp |
||
53 | * @return $this |
||
54 | */ |
||
55 | public function reverseSort($cmp = null) { |
||
58 | |||
59 | /** |
||
60 | * Iterates the collection and calls the callback function with the current item as parameter |
||
61 | * |
||
62 | * @param callable $callback |
||
63 | */ |
||
64 | public function each(callable $callback) { |
||
69 | |||
70 | /** |
||
71 | * Searches the collection with a given callback and returns the index for the first element if found. |
||
72 | * |
||
73 | * The callback function takes one or two parameters: |
||
74 | * |
||
75 | * function ($element [, $query]) {} |
||
76 | * |
||
77 | * The callback must return a boolean |
||
78 | * |
||
79 | * @param mixed $query OPTIONAL the provided query |
||
80 | * @param callable $callback the callback function |
||
81 | * @return int|null the index or null if it hasn't been found |
||
82 | */ |
||
83 | public function findIndex() { |
||
98 | |||
99 | /** |
||
100 | * Searches the collection with a given callback and returns the index for the last element if found. |
||
101 | * |
||
102 | * The callback function takes one or two parameters: |
||
103 | * |
||
104 | * function ($element [, $query]) {} |
||
105 | * |
||
106 | * The callback must return a boolean |
||
107 | * |
||
108 | * @param mixed $query OPTIONAL the provided query |
||
109 | * @param callable $callback the callback function |
||
110 | * @return int|null the index or null if it hasn't been found |
||
111 | */ |
||
112 | public function findLastIndex() { |
||
127 | } |
||
128 |