platform/api/symfony/Component/Form/Util/OrderedHashMap.yaml

186 lines
5.1 KiB
YAML
Raw Normal View History

2024-09-02 17:44:11 +00:00
name: OrderedHashMap
class_comment: '# * A hash map which keeps track of deletions and additions.
# *
# * Like in associative arrays, elements can be mapped to integer or string keys.
# * Unlike associative arrays, the map keeps track of the order in which keys
# * were added and removed. This order is reflected during iteration.
# *
# * The map supports concurrent modification during iteration. That means that
# * you can insert and remove elements from within a foreach loop and the
# * iterator will reflect those changes accordingly.
# *
# * While elements that are added during the loop are recognized by the iterator,
# * changed elements are not. Otherwise the loop could be infinite if each loop
# * changes the current element:
# *
# * $map = new OrderedHashMap();
# * $map[1] = 1;
# * $map[2] = 2;
# * $map[3] = 3;
# *
# * foreach ($map as $index => $value) {
# * echo "$index: $value\n"
# * if (1 === $index) {
# * $map[1] = 4;
# * $map[] = 5;
# * }
# * }
# *
# * print_r(iterator_to_array($map));
# *
# * // => 1: 1
# * // 2: 2
# * // 3: 3
# * // 4: 5
# * // Array
# * // (
# * // [1] => 4
# * // [2] => 2
# * // [3] => 3
# * // [4] => 5
# * // )
# *
# * The map also supports multiple parallel iterators. That means that you can
# * nest foreach loops without affecting each other''s iteration:
# *
# * foreach ($map as $index => $value) {
# * foreach ($map as $index2 => $value2) {
# * // ...
# * }
# * }
# *
# * @author Bernhard Schussek <bschussek@gmail.com>
# *
# * @template TValue
# *
# * @implements \ArrayAccess<string, TValue>
# * @implements \IteratorAggregate<string, TValue>'
dependencies: []
properties: []
methods:
- name: __construct
visibility: public
parameters:
- name: elements
default: '[]'
comment: "# * A hash map which keeps track of deletions and additions.\n# *\n# *\
\ Like in associative arrays, elements can be mapped to integer or string keys.\n\
# * Unlike associative arrays, the map keeps track of the order in which keys\n\
# * were added and removed. This order is reflected during iteration.\n# *\n#\
\ * The map supports concurrent modification during iteration. That means that\n\
# * you can insert and remove elements from within a foreach loop and the\n# *\
\ iterator will reflect those changes accordingly.\n# *\n# * While elements that\
\ are added during the loop are recognized by the iterator,\n# * changed elements\
\ are not. Otherwise the loop could be infinite if each loop\n# * changes the\
\ current element:\n# *\n# * $map = new OrderedHashMap();\n# * $map[1]\
\ = 1;\n# * $map[2] = 2;\n# * $map[3] = 3;\n# *\n# * foreach ($map\
\ as $index => $value) {\n# * echo \"$index: $value\\n\"\n# * \
\ if (1 === $index) {\n# * $map[1] = 4;\n# * $map[] =\
\ 5;\n# * }\n# * }\n# *\n# * print_r(iterator_to_array($map));\n\
# *\n# * // => 1: 1\n# * // 2: 2\n# * // 3: 3\n# * // \
\ 4: 5\n# * // Array\n# * // (\n# * // [1] => 4\n# *\
\ // [2] => 2\n# * // [3] => 3\n# * // [4] =>\
\ 5\n# * // )\n# *\n# * The map also supports multiple parallel iterators.\
\ That means that you can\n# * nest foreach loops without affecting each other's\
\ iteration:\n# *\n# * foreach ($map as $index => $value) {\n# * foreach\
\ ($map as $index2 => $value2) {\n# * // ...\n# * }\n# * \
\ }\n# *\n# * @author Bernhard Schussek <bschussek@gmail.com>\n# *\n# * @template\
\ TValue\n# *\n# * @implements \\ArrayAccess<string, TValue>\n# * @implements\
\ \\IteratorAggregate<string, TValue>\n# */\n# class OrderedHashMap implements\
\ \\ArrayAccess, \\IteratorAggregate, \\Countable\n# {\n# /**\n# * The keys of\
\ the map in the order in which they were inserted or changed.\n# *\n# * @var\
\ list<string>\n# */\n# private array $orderedKeys = [];\n# \n# /**\n# * References\
\ to the cursors of all open iterators.\n# *\n# * @var array<int, int>\n# */\n\
# private array $managedCursors = [];\n# \n# /**\n# * Creates a new map.\n# *\n\
# * @param TValue[] $elements The initial elements of the map, indexed by their\
\ keys"
- name: offsetExists
visibility: public
parameters:
- name: key
comment: null
- name: offsetGet
visibility: public
parameters:
- name: key
comment: null
- name: offsetSet
visibility: public
parameters:
- name: key
- name: value
comment: null
- name: offsetUnset
visibility: public
parameters:
- name: key
comment: null
- name: getIterator
visibility: public
parameters: []
comment: null
- name: count
visibility: public
parameters: []
comment: null
traits: []
interfaces:
- \ArrayAccess
- \IteratorAggregate
- \ArrayAccess