The Map class

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

简介

A Map is a sequential collection of key-value pairs, almost identical to an array used in a similar context. Keys can be any type, but must be unique. Values are replaced if added to the map using the same key.

Strengths

  • Keys and values can be any type, including objects.
  • Supports array syntax (square brackets).
  • Insertion order is preserved.
  • Performance and memory efficiency is very similar to an array.
  • Automatically frees allocated memory when its size drops low enough.

Weaknesses

  • Can't be converted to an array when objects are used as keys.

类摘要

Ds\Map implements Ds\Collection {
/* Constants */
const int MIN_CAPACITY = 16 ;
/* 方法 */
public allocate ( int $capacity ) : void
public apply ( callable $callback ) : void
public capacity ( void ) : int
public clear ( void ) : void
public copy ( void ) : Ds\Map
public diff ( Ds\Map $map ) : Ds\Map
public filter ([ callable $callback ] ) : Ds\Map
public first ( void ) : Ds\Pair
public get ( mixed $key [, mixed $default ] ) : mixed
public hasKey ( mixed $key ) : bool
public hasValue ( mixed $value ) : bool
public intersect ( Ds\Map $map ) : Ds\Map
public isEmpty ( void ) : bool
public keys ( void ) : Ds\Set
public ksort ([ callable $comparator ] ) : void
public ksorted ([ callable $comparator ] ) : Ds\Map
public last ( void ) : Ds\Pair
public map ( callable $callback ) : Ds\Map
public merge ( mixed $values ) : Ds\Map
public pairs ( void ) : Ds\Sequence
public put ( mixed $key , mixed $value ) : void
public putAll ( mixed $pairs ) : void
public reduce ( callable $callback [, mixed $initial ] ) : mixed
public remove ( mixed $key [, mixed $default ] ) : mixed
public reverse ( void ) : void
public reversed ( void ) : Ds\Map
public skip ( int $position ) : Ds\Pair
public slice ( int $index [, int $length ] ) : Ds\Map
public sort ([ callable $comparator ] ) : void
public sorted ([ callable $comparator ] ) : Ds\Map
public sum ( void ) : number
public toArray ( void ) : array
public union ( Ds\Map $map ) : Ds\Map
public values ( void ) : Ds\Sequence
public xor ( Ds\Map $map ) : Ds\Map
}

预定义常量

Ds\Map::MIN_CAPACITY

Table of Contents

User Contributed Notes

There are no user contributed notes for this page.