1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
pool.php
См. документацию.
1<?php
2namespace Bitrix\Location\Common;
3
8class Pool
9{
11 protected $poolSize = 0;
13 protected $items = [];
14
20 public function __construct(int $poolSize)
21 {
22 $this->poolSize = $poolSize;
23 }
24
28 public function getItems(): array
29 {
30 return $this->items;
31 }
32
33 public function cleanItems(): void
34 {
35 $this->items = [];
36 }
37
41 public function setItems(array $items): void
42 {
43 $this->items = $items;
44 }
45
50 public function getItem(string $index)
51 {
52 $result = null;
53
54 if(isset($this->items[$index]))
55 {
56 $result = $this->items[$index];
57 //come up used items
58 unset($this->items[$index]);
59 $this->items[$index] = $result;
60 }
61
62 return $result;
63 }
64
69 public function addItem(string $index, $value): void
70 {
71 $this->items[$index] = $value;
72 $delta = count($this->items) - $this->poolSize;
73
74 if($delta > 0)
75 {
76 $this->items = $this->decreaseSize($delta, $this->items);
77 }
78 }
79
83 public function getItemsCount(): int
84 {
85 return count($this->items);
86 }
87
91 public function deleteItem(string $index): void
92 {
93 if(isset($this->items[$index]))
94 {
95 unset($this->items[$index]);
96 }
97 }
98
104 protected function decreaseSize(int $delta, array $items): array
105 {
106 if($delta <= 0 || count($items) <= 0)
107 {
108 return $items;
109 }
110
111 do
112 {
113 reset($items);
114 unset($items[key($items)]);
115 $delta--;
116 }
117 while($delta > 0);
118
119 return $items;
120 }
121}
addItem(string $index, $value)
Определения pool.php:69
cleanItems()
Определения pool.php:33
$poolSize
Определения pool.php:11
setItems(array $items)
Определения pool.php:41
getItem(string $index)
Определения pool.php:50
__construct(int $poolSize)
Определения pool.php:20
deleteItem(string $index)
Определения pool.php:91
getItems()
Определения pool.php:28
decreaseSize(int $delta, array $items)
Определения pool.php:104
getItemsCount()
Определения pool.php:83
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$delta
Определения prolog_main_admin.php:363
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936