
- PHP Tutorial
- PHP - Home
- PHP - Introduction
- PHP - Environment Setup
- PHP - Syntax Overview
- PHP - Variable Types
- PHP - Constants
- PHP - Operator Types
- PHP - Decision Making
- PHP - Loop Types
- PHP - Arrays
- PHP - Strings
- PHP - Web Concepts
- PHP - GET & POST
- PHP - File Inclusion
- PHP - Files & I/O
- PHP - Functions
- PHP - Cookies
- PHP - Sessions
- PHP - Sending Emails
- PHP - File Uploading
- PHP - Coding Standard
- Advanced PHP
- PHP - Predefined Variables
- PHP - Regular Expression
- PHP - Error Handling
- PHP - Bugs Debugging
- PHP - Date & Time
- PHP & MySQL
- PHP & AJAX
- PHP & XML
- PHP - Object Oriented
- PHP - For C Developers
- PHP - For PERL Developers
- PHP Form Examples
- PHP - Form Introduction
- PHP - Validation Example
- PHP - Complete Form
- PHP login Examples
- PHP - Login Example
- PHP - Facebook Login
- PHP - Paypal Integration
- PHP - MySQL Login
- PHP AJAX Examples
- PHP - AJAX Search
- PHP - AJAX XML Parser
- PHP - AJAX Auto Complete Search
- PHP - AJAX RSS Feed Example
- PHP XML Example
- PHP - XML Introduction
- PHP - Simple XML
- PHP - Simple XML GET
- PHP - SAX Parser Example
- PHP - DOM Parser Example
- PHP Frame Works
- PHP - Frame Works
- PHP - Core PHP vs Frame Works
- PHP Design Patterns
- PHP - Design Patterns
- PHP Function Reference
- PHP - Built-In Functions
- PHP Useful Resources
- PHP - Questions & Answers
- PHP - Useful Resources
- PHP - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP - Sequence Functions
Introduction to Sequence interface
A Sequence can 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, with the exception of a few characteristics.
- 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
- Wherever we can use an array as a list (not concerned with keys).
- A more efficient alternative to SplDoublyLinkedList and SplFixedArray.
Interface synopsis
Ds\Sequence implements Ds\Collection { /* Methods */ abstract public void allocate( int $capacity ) abstract public void apply( callable $callback ) abstract public int capacity( void ) abstract public bool contains([ mixed $...values ] ) abstract public Ds\Sequence filter([ callable $callback ] ) abstract public mixed find( mixed $value ) abstract public mixed first( void ) abstract public mixed get( int $index ) abstract public void insert( int $index [, mixed $...values ] ) abstract public string join([ string $glue ] ) abstract public mixed last( void ) abstract public Ds\Sequence map( callable $callback ) abstract public Ds\Sequence merge( mixed $values ) abstract public mixed pop( void ) abstract public void push([ mixed $...values ] ) abstract public mixed reduce( callable $callback [, mixed $initial ] ) abstract public mixed remove( int $index ) abstract public void reverse( void ) abstract public Ds\Sequence reversed( void ) abstract public void rotate( int $rotations ) abstract public void set( int $index , mixed $value ) abstract public mixed shift( void ) abstract public Ds\Sequence slice( int $index [, int $length ] ) abstract public void sort([ callable $comparator ] ) abstract public Ds\Sequence sorted([ callable $comparator ] ) abstract public number sum( void ) abstract public void unshift([ mixed $values ] ) }
Predefined Constants
Ds\Map::MIN_CAPACITY
Sr.No | Function & Description |
---|---|
1 |
This Function can allocate enough memory for a required capacity. |
2 |
This Function can update all values by applying a callback function to each value. |
3 |
This Function can return the current capacity. |
4 |
This Function can determine if a sequence contains given values. |
5 |
create a new sequence using callable to determine which values to include. |
6 |
This Function can attempt to find the value's index. |
7 |
This Function can can return the first value in a sequence.. |
8 |
This Function can return the value at a given index. |
9 |
This Function can insert values at a given index. |
10 |
This Function can join all values together as a string. |
11 |
This Function can return the last value. |
12 |
This Function can return the result of applying a callback to each value. |
13 |
This Function can return the result of adding all given values to the sequence. |
14 |
This Function can remove and return the last value. |
15 |
This Function can add values to the end of a sequence. |
16 |
This Function can reduce the sequence to a single value using a callback function. |
17 |
This Function can remove and return a value by index. |
18 |
This Function can can reverse a sequence in-place. |
19 |
This Function can return a reversed copy. |
20 |
This Function can rotate the sequence by given number of rotations. |
21 |
This Function can update a value at the given index. |
22 |
This Function can remove and return a first value. |
23 |
This Function can return a sub-sequence of the given range. |
24 |
This Function can sort a sequence in-place. |
25 |
This Function can return a sorted copy. |
26 |
This Function can return the sum of all values in a sequence. |
27 |
This Function add values to the front of a sequence. |