Geen cache-versie.


Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code LNG204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.

Rechercher une fonction PHP

The Deque class

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

Introduction

A Deque (pronounced “deck”) is a sequence of values in a contiguous buffer that grows and shrinks automatically. The name is a common abbreviation of “double-ended queue” and is used internally by Ds\Queue.

Two pointers are used to keep track of a head and a tail. The pointers can “wrap around” the end of the buffer, which avoids the need to move other values around to make room. This makes shift and unshift very fast —  something a Ds\Vector can’t compete with.

Accessing a value by index requires a translation between the index and its corresponding position in the buffer: ((head + position) % capacity).

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

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.
  • get(), set(), push(), pop(), shift(), and unshift() are all O(1).

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Weaknesses

  • Capacity must be a power of 2.
  • insert() and remove() are O(n).

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Class synopsis

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

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Predefined Constants

Ds\Deque::MIN_CAPACITY

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Table of Contents

Zoek een PHP-functie

Vertaling niet beschikbaar

De PHP-handleiding is nog niet in het Nederlands vertaald, dus het scherm is in het Engels. Als u wilt, kunt u het ook in het Frans of in het Duits raadplegen.

Als je de moed voelt, kun je je vertaling aanbieden ;-)

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 30/01/2003 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/php-rf-class.ds-deque.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : http://php.net

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut