The Sequence interface

(No version information available, might only be in Git)

Introduction

A Sequence describes the behaviour of values arranged in a single, linear dimension. Some languages refer to this as a "List". It’s similar to an array that uses incremental integer keys, with the exception of a few characteristics:

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

Use cases:

Sommaire de l'Interface

Ds\Sequence implements Ds\Collection {
/* Méthodes */
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 ] )
}

Sommaire

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top