<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.ds-deque.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'ds-deque.slice.php',
    1 => 'Ds\\Deque::slice',
    2 => 'Returns a sub-deque of a given range',
  ),
  'up' => 
  array (
    0 => 'class.ds-deque.php',
    1 => 'Ds\\Deque',
  ),
  'prev' => 
  array (
    0 => 'ds-deque.shift.php',
    1 => 'Ds\\Deque::shift',
  ),
  'next' => 
  array (
    0 => 'ds-deque.sort.php',
    1 => 'Ds\\Deque::sort',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/ds/ds/deque/slice.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="ds-deque.slice" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Ds\Deque::slice</h1>
  <p class="verinfo">(PECL ds &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Ds\Deque::slice</span> &mdash; <span class="dc-title">
   Returns a sub-deque of a given range
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-ds-deque.slice-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Ds\Deque::slice</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$index</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$length</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="class.ds-deque.php" class="type Ds\Deque">Ds\Deque</a></span></div>

  <p class="para rdfs-comment">
    Creates a sub-deque of a given range.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-ds-deque.slice-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">index</code></dt>
    <dd>
        <p class="para">
            The index at which the sub-deque starts.
        </p>
        <p class="para">
            If positive, the deque will start at that index in the deque.
            If negative, the deque will start that far from the end.
        </p>
    </dd>
    
    
    <dt><code class="parameter">length</code></dt>
    <dd>
     <p class="para">
        If a length is given and is positive, the resulting
        deque will have up to that many values in it.

        If the length results in an overflow, only
        values up to the end of the deque will be included.

        If a length is given and is negative, the deque
        will stop that many values from the end.

        If a length is not provided, the resulting deque
        will contain all values between the index and the
        end of the deque.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-ds-deque.slice-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
    A sub-deque of the given range.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-ds-deque.slice-examples">
  <h3 class="title">示例</h3>
  <div class="example" id="example-1">
   <p><strong>示例 #1 <span class="function"><strong>Ds\Deque::slice()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$deque </span><span style="color: #007700">= new </span><span style="color: #0000BB">\Ds\Deque</span><span style="color: #007700">([</span><span style="color: #DD0000">"a"</span><span style="color: #007700">, </span><span style="color: #DD0000">"b"</span><span style="color: #007700">, </span><span style="color: #DD0000">"c"</span><span style="color: #007700">, </span><span style="color: #DD0000">"d"</span><span style="color: #007700">, </span><span style="color: #DD0000">"e"</span><span style="color: #007700">]);<br /><br /></span><span style="color: #FF8000">// Slice from 2 onwards<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$deque</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">slice</span><span style="color: #007700">(</span><span style="color: #0000BB">2</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Slice from 1, for a length of 3<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$deque</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">slice</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Slice from 1 onwards<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$deque</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">slice</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Slice from 2 from the end onwards<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$deque</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">slice</span><span style="color: #007700">(-</span><span style="color: #0000BB">2</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Slice from 1 to 1 from the end<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$deque</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">slice</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, -</span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>以上示例的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Ds\Deque Object
(
    [0] =&gt; c
    [1] =&gt; d
    [2] =&gt; e
)
Ds\Deque Object
(
    [0] =&gt; b
    [1] =&gt; c
    [2] =&gt; d
)
Ds\Deque Object
(
    [0] =&gt; b
    [1] =&gt; c
    [2] =&gt; d
    [3] =&gt; e
)
Ds\Deque Object
(
    [0] =&gt; d
    [1] =&gt; e
)
Ds\Deque Object
(
    [0] =&gt; b
    [1] =&gt; c
    [2] =&gt; d
)</pre>
</div>
   </div>
  </div>
 </div>



</div><?php manual_footer($setup); ?>