1
0
mirror of https://github.com/php/doc-fr.git synced 2026-03-24 07:02:06 +01:00
Files
archived-doc-fr/reference/spl/seekableiterator.xml
Louis-Arnaud 8da8c3fe7a sync EN-Revision hashes and apply pending EN changes (#2465)
* sync EN-Revision hashes and apply pending EN changes
2026-02-12 11:04:51 +01:00

160 lines
3.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 4d17b7b4947e7819ff5036715dd706be87ae4def Maintainer: yannick Status: ready -->
<!-- Reviewed: yes -->
<reference xml:id="class.seekableiterator" role="class" 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 class="interface">
<oointerface>
<interfacename>SeekableIterator</interfacename>
</oointerface>
<oointerface>
<modifier>extends</modifier>
<interfacename>Iterator</interfacename>
</oointerface>
<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[@role='SeekableIterator'])">
<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[@role='Iterator'])">
<xi:fallback/>
</xi:include>
</classsynopsis>
<!-- }}} -->
</section>
<section xml:id="seekableiterator.examples">
&reftitle.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;
</reference>
<!-- 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
-->