Sequence 接口

(PECL ds >= 1.0.0)

介绍

Sequence 描述了以单一线性维度排列的值的行为。一些语言将其称为“列表”。它类似于使用增量整数键的数组,但有一些区别

  • 值将始终被索引为 [0, 1, 2, …, size - 1]。
  • 仅允许通过索引在范围 [0, size - 1] 内访问值。

用例

接口概要

interface Ds\Sequence extends Ds\Collection, ArrayAccess {
/* 方法 */
abstract public allocate(int $capacity): void
abstract public apply(callable $callback): void
abstract public capacity(): int
abstract public contains(mixed ...$values): bool
abstract public filter(callable $callback = ?): Ds\Sequence
abstract public find(mixed $value): mixed
abstract public first(): mixed
abstract public get(int $index): mixed
abstract public insert(int $index, mixed ...$values): void
abstract public join(string $glue = ?): string
abstract public last(): mixed
abstract public map(callable $callback): Ds\Sequence
abstract public merge(mixed $values): Ds\Sequence
abstract public pop(): mixed
abstract public push(mixed ...$values): void
abstract public reduce(callable $callback, mixed $initial = ?): mixed
abstract public remove(int $index): mixed
abstract public reverse(): void
abstract public reversed(): Ds\Sequence
abstract public rotate(int $rotations): void
abstract public set(int $index, mixed $value): void
abstract public shift(): mixed
abstract public slice(int $index, int $length = ?): Ds\Sequence
abstract public sort(callable $comparator = ?): void
abstract public sorted(callable $comparator = ?): Ds\Sequence
abstract public sum(): int|float
abstract public unshift(mixed $values = ?): void
/* 继承的方法 */
public ArrayAccess::offsetSet(混合 $offset, 混合 $value):
}

变更日志

版本 描述
PECL ds 1.3.0 该接口现在扩展了 ArrayAccess

目录

添加一个注释

用户贡献的注释

此页面没有用户贡献的注释。
To Top