Files
doc-fr/reference/spl/seekableiterator.xml
Sergey Panteleev 9584b10b52 Sync SPL stub changes with English (#139)
Co-authored-by: George Peter Banyard <girgias@php.net>
2021-12-22 15:29:45 +00:00

166 lines
4.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: c80e398bcb1f060d16de768e46933d1a09f2de65 Maintainer: yannick Status: ready -->
<!-- Reviewed: yes -->
<phpdoc:classref xml:id="class.seekableiterator" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>L'interface <classname>SeekableIterator</classname></title>
<titleabbrev>SeekableIterator</titleabbrev>
<partintro>
<!-- {{{ SeekableIterator intro -->
<section xml:id="seekableiterator.intro">
&reftitle.intro;
<para>
L'itérateur <classname>SeekableIterator</classname>.
</para>
</section>
<!-- }}} -->
<section xml:id="seekableiterator.synopsis">
&reftitle.interfacesynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass>
<classname>SeekableIterator</classname>
</ooclass>
<classsynopsisinfo>
<oointerface>
<interfacename>SeekableIterator</interfacename>
</oointerface>
<ooclass>
<modifier>extends</modifier>
<classname>Iterator</classname>
</ooclass>
</classsynopsisinfo>
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.seekableiterator')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])">
<xi:fallback/>
</xi:include>
<classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.iterator')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])">
<xi:fallback/>
</xi:include>
</classsynopsis>
<!-- }}} -->
</section>
<section xml:id="seekableiterator.examples">
<example xml:id="seekableiterator.examples.basic"><!-- {{{ -->
<title>Utilisation simple</title>
<para>
Cet exemple montre comment crée une classe
<classname>SeekableIterator</classname> personnalisée,
qui gère une position invalide.
</para>
<programlisting role="php">
<![CDATA[
<?php
class MySeekableIterator implements SeekableIterator {
private $position;
private $array = array(
"premier élément",
"second élément",
"troisième élément",
"quatriéme élément"
);
/* Méthode requis pour l'interface SeekableIterator */
public function seek($position) {
if (!isset($this->array[$position])) {
throw new OutOfBoundsException("position invalide ($position)");
}
$this->position = $position;
}
/* Méthodes requises par l'interface Iterator */
public function rewind() {
$this->position = 0;
}
public function current() {
return $this->array[$this->position];
}
public function key() {
return $this->position;
}
public function next() {
++$this->position;
}
public function valid() {
return isset($this->array[$this->position]);
}
}
try {
$it = new MySeekableIterator;
echo $it->current(), "\n";
$it->seek(2);
echo $it->current(), "\n";
$it->seek(1);
echo $it->current(), "\n";
$it->seek(10);
} catch (OutOfBoundsException $e) {
echo $e->getMessage();
}
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
premier élément
troisième élément
second élément
position invalide (10)
]]>
</screen>
</example><!-- }}} -->
</section>
</partintro>
&reference.spl.entities.seekableiterator;
</phpdoc:classref>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->