Skip to content

Conversation

@LeonMelis
Copy link
Contributor

9 years ago (back in the PHP 5.5 days), the PECL ds codebase was updated to use 8 as minimal size of various vector and hash table implementations as part of the PECL DS 1.2.0 release (released August 3rd, 2017). The PHP documentation was never updated though.

This PR updates the documentation values to all reflect the correct MIN_CAPACITY constant value for the various PECL DS classes. This PR also adds this to the changelog entries, for sake of completeness.

See:

And a few of the specific commits:

The following code verifies that all default/minimal capacities in the various DS classes are indeed set to 8:

<?php

$classes = [
    \Ds\Vector::class,
    \Ds\Deque::class,
    \Ds\Map::class,
    \Ds\Set::class,
    \Ds\Stack::class,
    \Ds\Queue::class,
    \Ds\PriorityQueue::class,
];

foreach ($classes as $class) {
    $instance = new $class();
    $constant = defined("$class::MIN_CAPACITY") ? $class::MIN_CAPACITY : '<not defined>';
    echo "{$class}: constant={$constant} capacity={$instance->capacity()}\n";
}

Expected output (on any PECL version >=1.2.0 and/or PHP >=5.6):

Ds\Vector: constant=8 capacity=8
Ds\Deque: constant=8 capacity=8
Ds\Map: constant=8 capacity=8
Ds\Set: constant=8 capacity=8
Ds\Stack: constant=<not defined> capacity=8
Ds\Queue: constant=8 capacity=8
Ds\PriorityQueue: constant=8 capacity=8

I also checked the documentation for the other DS classes, those al seem to be correct.

The MIN_CAPACITY was changed in PECL DS library from 16 to 8 in July 2017.
See: php-ds/ext-ds@9904fca
Update \Ds\Set::MIN_CAPACITY to reflect actual value

The MIN_CAPACITY was changed in PECL DS library from 16 to 8 in July 2017.

See: php-ds/ext-ds@9904fca
Update \Ds\Vector::MIN_CAPACITY to reflect actual value

The MIN_CAPACITY was changed in PECL DS library from 16 to 8 in July 2017.

See: php-ds/ext-ds@9904fca
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@Girgias Girgias merged commit 94b069b into php:master Jan 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants