mirror of
https://github.com/php/doc-es.git
synced 2026-03-25 16:02:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@334045 c90b9560-bf6c-de11-be94-00142212c4b1
163 lines
4.0 KiB
XML
163 lines
4.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: f4aa62f2856ac1429c254c475695c4f5b7b20142 Maintainer: andresdzphp Status: ready -->
|
|
<!-- Reviewed: yes Maintainer: seros -->
|
|
|
|
<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>La interfaz SeekableIterator</title>
|
|
<titleabbrev>SeekableIterator</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
<!-- {{{ SeekableIterator intro -->
|
|
<section xml:id="seekableiterator.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
El iterador Seekable.
|
|
</para>
|
|
</section>
|
|
<!-- }}} -->
|
|
|
|
<section xml:id="seekableiterator.synopsis">
|
|
&reftitle.interfacesynopsis;
|
|
|
|
<!-- {{{ Synopsis -->
|
|
<classsynopsis>
|
|
<ooclass><classname>SeekableIterator</classname></ooclass>
|
|
|
|
<!-- {{{ Class synopsis -->
|
|
<classsynopsisinfo>
|
|
<ooclass>
|
|
<classname>SeekableIterator</classname>
|
|
</ooclass>
|
|
|
|
<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[1])" />
|
|
|
|
<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[1])" />
|
|
</classsynopsis>
|
|
<!-- }}} -->
|
|
|
|
</section>
|
|
|
|
<section xml:id="seekableiterator.examples">
|
|
<example xml:id="seekableiterator.examples.basic"><!-- {{{ -->
|
|
<title>Uso básico</title>
|
|
<para>
|
|
Este ejemplo muestra cómo crear un <classname>SeekableIterator</classname> personalizado,
|
|
buscar una posición y manejar una posición inválida.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class MiSeekableIterator implements SeekableIterator {
|
|
|
|
private $posición = 0;
|
|
|
|
private $array = array(
|
|
"primer elemento",
|
|
"segundo elemento",
|
|
"tercer elemento",
|
|
"cuarto elemento"
|
|
);
|
|
|
|
/* Métodos requeridos para la interfaz SeekableIterator */
|
|
|
|
public function seek($posición) {
|
|
if (!isset($this->array[$posición])) {
|
|
throw new OutOfBoundsException("Posición de búsqueda inválida ($posición)");
|
|
}
|
|
|
|
$this->posición = $posición;
|
|
}
|
|
|
|
/* Métodos requeridos para la interfaz Iterador */
|
|
|
|
public function rewind() {
|
|
$this->posición = 0;
|
|
}
|
|
|
|
public function current() {
|
|
return $this->array[$this->posición];
|
|
}
|
|
|
|
public function key() {
|
|
return $this->posición;
|
|
}
|
|
|
|
public function next() {
|
|
++$this->posición;
|
|
}
|
|
|
|
public function valid() {
|
|
return isset($this->array[$this->posición]);
|
|
}
|
|
}
|
|
|
|
try {
|
|
|
|
$it = new MiSeekableIterator;
|
|
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[
|
|
primer elemento
|
|
tercer elemento
|
|
segundo elemento
|
|
Posición de búsqueda inválida (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
|
|
-->
|