No cache version.


Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

The Map class

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

Introduction

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.

PHP: Map - Manual Home of Manuel PHP  Contents Haut

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.

PHP: Map - Manual Home of Manuel PHP  Contents Haut

Weaknesses

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

PHP: Map - Manual Home of Manuel PHP  Contents Haut

Class synopsis

Ds\Map implements Ds\Collection {
/* Constants */
const int MIN_CAPACITY = 16 ;
/* Methods */
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
}

PHP: Map - Manual Home of Manuel PHP  Contents Haut

Predefined Constants

Ds\Map::MIN_CAPACITY

PHP: Map - Manual Home of Manuel PHP  Contents Haut

Table of Contents

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-class.ds-map.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut