Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

PHP - Sequence Functions



ASequencecan describe the behavior of values arranged in a single, linear dimension. Some languages can refer to this as a List. It is similar to an array that uses incremental integer keys, except for a few characteristics.

Following are a few important points about the sequence −

  • Values can always be indexed as [0, 1, 2, , size - 1].
  • Only allowed to access values by index in the range [0, size - 1].

Use cases

Below are the use cases of sequence −

  • Wherever we can use an array as a list (not concerned with keys).
  • A more efficient alternative to SplDoublyLinkedList and SplFixedArray.

List of Functions

Below of the list of functions provided by the the Sequence class −

Sr.No Function & Description
1

Ds\Sequence::allocate()

This Function can allocate enough memory for a required capacity.

2

Ds\Sequence::apply()

This Function can update all values by applying a callback function to each value.

3

Ds\Sequence::capacity()

This Function can return the current capacity.

4

Ds\Sequence::contains()

This Function can determine if a sequence contains given values.

5

Ds\Sequence::filter()

create a new sequence using callable to determine which values to include.

6

Ds\Sequence::find()

This Function can attempt to find the value's index.

7

Ds\Sequence::first()

This Function can can return the first value in a sequence..

8

Ds\Sequence::get()

This Function can return the value at a given index.

9

Ds\Sequence::insert()

This Function can insert values at a given index.

10

Ds\Sequence::join()

This Function can join all values together as a string.

11

Ds\Sequence::last()

This Function can return the last value.

12

Ds\Sequence::map()

This Function can return the result of applying a callback to each value.

13

Ds\Sequence::merge()

This Function can return the result of adding all given values to the sequence.

14

Ds\Sequence::pop()

This Function can remove and return the last value.

15

Ds\Sequence::push()

This Function can add values to the end of a sequence.

16

Ds\Sequence::reduce()

This Function can reduce the sequence to a single value using a callback function.

17

Ds\Sequence::remove()

This Function can remove and return a value by index.

18

Ds\Sequence::reverse()

This Function can can reverse a sequence in-place.

19

Ds\Sequence::reversed()

This Function can return a reversed copy.

20

Ds\Sequence::rotate()

This Function can rotate the sequence by given number of rotations.

21

Ds\Sequence::set()

This Function can update a value at the given index.

22

Ds\Sequence::shift()

This Function can remove and return a first value.

23

Ds\Sequence::slice()

This Function can return a sub-sequence of the given range.

24

Ds\Sequence::sort()

This Function can sort a sequence in-place.

25

Ds\Sequence::sorted()

This Function can return a sorted copy.

26

Ds\Sequence::sum()

This Function can return the sum of all values in a sequence.

27

Ds\Sequence::unshift()

This Function add values to the front of a sequence.

php_function_reference.htm
Advertisements