Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
nodelist.php
1<?php
2namespace Bitrix\Main\Web\DOM;
3
4/*
5class NodeList extends \Bitrix\Main\Type\Dictionary implements \Traversable
6{
7 public function item($index)
8 {
9 return $this->offsetGet($index);
10 }
11
12 public function haveItem(Node $item)
13 {
14 for($i = 0; $i < $this->count(); $i++)
15 {
16 if($item->isEqual($this->item($i)))
17 {
18 return true;
19 }
20 }
21
22 return false;
23 }
24
25 public function removeItem(Node $item)
26 {
27 for($i = 0; $i < $this->count(); $i++)
28 {
29 if($item === $this->item($i))
30 {
31 $this->offsetUnset($i);
32 break;
33 }
34 }
35 }
36}
37*/
38
39class NodeList implements \Iterator {
40 protected $length = 0;
41 protected $position = 0;
42 protected $values = array();
43
44 public function __construct(array $values = null)
45 {
46 if($values === null)
47 {
48 $this->position = 0;
49 $this->set($values);
50 }
51 }
52
53 public function getLength()
54 {
55 return $this->length;
56 }
57
58 /*
59 * @return Node|null
60 */
61 public function item($index)
62 {
63 if($this->valid($index))
64 {
65 return $this->values[$index];
66 }
67
68 return null;
69 }
70
71 public function set(array $values)
72 {
73 $this->values = array_values($values);
74 $this->length = count($this->values);
75 }
76
77 public function get()
78 {
79 return $this->values;
80 }
81
82 public function rewind()
83 {
84 $this->position = 0;
85 }
86
87 public function current()
88 {
89 return $this->values[$this->position];
90 }
91
92 public function key()
93 {
94 return $this->position;
95 }
96
97 public function next()
98 {
100 }
101
102 public function valid($index = null)
103 {
104 if($index === null)
105 {
106 $index = $this->position;
107 }
108
109 return isset($this->values[$index]);
110 }
111}
__construct(array $values=null)
Definition nodelist.php:44