The Vector class

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

Einführung

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).

Klassenbeschreibung

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

Vordefinierte Konstanten

Ds\Vector::MIN_CAPACITY

Changelog

Version Beschreibung
PECL ds 1.3.0 The class now implements ArrayAccess.

Inhaltsverzeichnis

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Buy Canadian Visa WhatAp +4915733512463 Buy USA passport Buy Japanese passport

Buy counterfeit RMB (CNY), (WeChat: Johnyj55) Buy counterfeit RMB/CNY, https://legitdocs48hrs.com/ Counterfeit RMB | CNY, Buy counterfeit RMB, Buy ...

Geschrieben von jeneed am 14.06.2026 08:26:07
Forum: PHP Developer Forum
kaufen MPU und Goethe zertifikat WhatsApp; +4915733512463

Um einen deutschen Führerschein zu erhalten, müssen Sie eine https://fuhhrerschein48hrs.de/deutscher-fuhrerschein/ (http://fuhhrerschein48hrs.d ...

Geschrieben von jeneed am 14.06.2026 08:25:34
Forum: News / Kostenloses
[FULLLZ.Asia] ⚡ Sell Passport Photos Front back with Selfie INFO FULLZ

[FULLLZ.Asia] ⚡ SELL DUMPS APPROVED TRACK 1&2 CASHAPP PAYPAL TRANSFER STORE CC+CVV INFO FULLZ DL/SSN+DOB/CHECKER/MMN/PAYPAL [FULLLZ.Asia] ⚡ Se ...

Geschrieben von dumpstop10 am 14.06.2026 08:21:22
Forum: Grafik / Design / Flash ...
kaufen MPU und Goethe zertifikat WhatsApp; +4915733512463

Um einen deutschen Führerschein zu erhalten, müssen Sie eine https://fuhhrerschein48hrs.de/deutscher-fuhrerschein/ (http://fuhhrerschein48hrs.d ...

Geschrieben von jeneed am 14.06.2026 08:20:17
Forum: Fragen/Vorschläge zum Forum