PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

The Vector class | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

The Vector class

(バージョン情報なし。おそらく SVN 版にしか存在しないでしょう)

はじめに

A Vector is a sequence of values in a contiguous buffer that grows and shrinks automatically. It’s the most efficient sequential structure because a value’s index is a direct mapping to its index in the buffer, and the growth factor isn't bound to a specific multiple or exponent.

Strengths

  • Supports array syntax (square brackets).
  • Uses less overall memory than an array for the same number of values.
  • Automatically frees allocated memory when its size drops low enough.
  • Capacity does not have to be a power of 2.
  • get(), set(), push(), pop() are all O(1).

Weaknesses

  • shift(), unshift(), insert() and remove() are all O(n).

クラス概要

Ds\Vector implements Ds\Sequence {
/* Constants */
const int MIN_CAPACITY = 10 ;
/* メソッド */
public void allocate ( int $capacity )
public void apply ( callable $callback )
public int capacity ( void )
public void clear ( void )
public bool contains ([ mixed $...values ] )
public Ds\Vector copy ( void )
public Ds\Vector filter ([ callable $callback ] )
public mixed find ( mixed $value )
public mixed first ( void )
public mixed get ( int $index )
public void insert ( int $index [, mixed $...values ] )
public bool isEmpty ( void )
public string join ([ string $glue ] )
public mixed last ( void )
public Ds\Vector map ( callable $callback )
public Ds\Vector merge ( mixed $values )
public mixed pop ( void )
public void push ([ mixed $...values ] )
public mixed reduce ( callable $callback [, mixed $initial ] )
public mixed remove ( int $index )
public void reverse ( void )
public Ds\Vector reversed ( void )
public void rotate ( int $rotations )
public void set ( int $index , mixed $value )
public mixed shift ( void )
public Ds\Vector slice ( int $index [, int $length ] )
public void sort ([ callable $comparator ] )
public Ds\Vector sorted ([ callable $comparator ] )
public number sum ( void )
public array toArray ( void )
public void unshift ([ mixed $values ] )
}

定義済み定数

Ds\Vector::MIN_CAPACITY

目次


忘却曲線を使ってこの知識を確実に記憶に残す

フォーラムで「The Vector class」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | The Vector class」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: