[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Capacity.php
<?php namespace Ds\Traits; use Ds\Deque; /** * Common to structures that deal with an internal capacity. While none of the * PHP implementations actually make use of a capacity, it's important to keep * consistent with the extension. */ trait Capacity { /** * @var int internal capacity */ private $capacity = self::MIN_CAPACITY; /** * Returns the current capacity. */ public function capacity(): int { return $this->capacity; } /** * Ensures that enough memory is allocated for a specified capacity. This * potentially reduces the number of reallocations as the size increases. * * @param int $capacity The number of values for which capacity should be * allocated. Capacity will stay the same if this value * is less than or equal to the current capacity. */ public function allocate(int $capacity) { $this->capacity = max($capacity, $this->capacity); } /** * @return float the structures growth factor. */ protected function getGrowthFactor(): float { return 2; } /** * @return float to multiply by when decreasing capacity. */ protected function getDecayFactor(): float { return 0.5; } /** * @return float the ratio between size and capacity when capacity should be * decreased. */ protected function getTruncateThreshold(): float { return 0.25; } /** * Checks and adjusts capacity if required. */ protected function checkCapacity() { if ($this->shouldIncreaseCapacity()) { $this->increaseCapacity(); } else { if ($this->shouldDecreaseCapacity()) { $this->decreaseCapacity(); } } } /** * @param int $total */ protected function ensureCapacity(int $total) { if ($total > $this->capacity()) { $this->capacity = max($total, $this->nextCapacity()); } } /** * @return bool whether capacity should be increased. */ protected function shouldIncreaseCapacity(): bool { return $this->count() >= $this->capacity(); } protected function nextCapacity(): int { return (int) ($this->capacity() * $this->getGrowthFactor()); } /** * Called when capacity should be increased to accommodate new values. */ protected function increaseCapacity() { $this->capacity = max( $this->count(), $this->nextCapacity() ); } /** * Called when capacity should be decrease if it drops below a threshold. */ protected function decreaseCapacity() { $this->capacity = max( self::MIN_CAPACITY, (int) ($this->capacity() * $this->getDecayFactor()) ); } /** * @return bool whether capacity should be increased. */ protected function shouldDecreaseCapacity(): bool { return count($this) <= $this->capacity() * $this->getTruncateThreshold(); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002