<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/book.ds.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'tr',
  ),
  'this' => 
  array (
    0 => 'class.ds-deque.php',
    1 => 'Ds\\Deque',
    2 => 'The Deque class',
  ),
  'up' => 
  array (
    0 => 'book.ds.php',
    1 => 'Data Structures',
  ),
  'prev' => 
  array (
    0 => 'ds-vector.unshift.php',
    1 => 'Ds\\Vector::unshift',
  ),
  'next' => 
  array (
    0 => 'ds-deque.allocate.php',
    1 => 'Ds\\Deque::allocate',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/ds/ds.deque.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/class.ds-deque.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="class.ds-deque" class="reference">

 <h1 class="title">The Deque class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL ds &gt;= 1.0.0)</p>


  <div class="section" id="ds-deque.intro">
   <h2 class="title">Giriş</h2>
   <p class="para">
    A Deque (pronounced “deck”) is a sequence of values
    in a contiguous buffer that grows and shrinks automatically.
    The name is a common abbreviation of “double-ended queue” and is used
    internally by <span class="classname"><a href="class.ds-queue.php" class="classname">Ds\Queue</a></span>.
   </p>
   <p class="para">
    Two pointers are used to keep track of a head and a tail. The pointers can
    “wrap around” the end of the buffer, which avoids the need to move other
    values around to make room. This makes shift and unshift very fast — 
    something a <span class="classname"><a href="class.ds-vector.php" class="classname">Ds\Vector</a></span> can’t compete with.
   </p>
   <p class="para">
    Accessing a value by index requires a translation between the index and its
    corresponding position in the buffer: <code class="code">((head + position) % capacity)</code>.
   </p>
  </div>


<div class="section" id="ds-deque.strengths">
    <h2 class="title">Strengths</h2>
    <p class="para">
        <ul class="simplelist">
            <li>Supports array syntax (square brackets).</li>
            <li>Uses less overall memory than an <span class="type"><a href="language.types.array.php" class="type array">array</a></span> for the same number of values.</li>
            <li>Automatically frees allocated memory when its size drops low enough.</li>
            <li>
                <span class="function"><strong>get()</strong></span>,
                <span class="function"><strong>set()</strong></span>,
                <span class="function"><strong>push()</strong></span>,
                <span class="function"><strong>pop()</strong></span>,
                <span class="function"><strong>shift()</strong></span>, and
                <span class="function"><strong>unshift()</strong></span> are all O(1).
            </li>
        </ul>
   </p>
</div>

<div class="section" id="ds-deque.weaknesses">
    <h2 class="title">Weaknesses</h2>
    <p class="para">
        <ul class="simplelist">
            <li>Capacity must be a power of 2.</li>
            <li>
                <span class="function"><strong>insert()</strong></span> and
                <span class="function"><strong>remove()</strong></span> are O(n).
            </li>
        </ul>
   </p>
</div>

  <div class="section" id="ds-deque.synopsis">
   <h2 class="title">Sınıf Sözdizimi</h2>


   <div class="classsynopsis">
    <span class="ooclass"><strong class="classname"></strong></span>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">Ds\Deque</strong>
     </span>

     <span class="oointerface"><span class="modifier">implements</span> 
       <a href="class.ds-sequence.php" class="interfacename">Ds\Sequence</a></span><span class="oointerface">,  <a href="class.arrayaccess.php" class="interfacename">ArrayAccess</a></span> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Sabitler */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
      <var class="fieldsynopsis_varname"><a href="class.ds-deque.php#ds-deque.constants.min-capacity"><var class="varname">MIN_CAPACITY</var></a></var><span class="initializer"> = 8</span>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Yöntemler */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="ds-deque.allocate.php" class="methodname">allocate</a></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$capacity</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.apply.php" class="methodname">apply</a></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.capacity.php" class="methodname">capacity</a></span>(): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.clear.php" class="methodname">clear</a></span>(): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.contains.php" class="methodname">contains</a></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">...$values</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.copy.php" class="methodname">copy</a></span>(): <span class="type"><a href="class.ds-deque.php" class="type Ds\Deque">Ds\Deque</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.filter.php" class="methodname">filter</a></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$callback</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="class.ds-deque.php" class="type Ds\Deque">Ds\Deque</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.find.php" class="methodname">find</a></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.first.php" class="methodname">first</a></span>(): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.get.php" class="methodname">get</a></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="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.insert.php" class="methodname">insert</a></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.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">...$values</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.isempty.php" class="methodname">isEmpty</a></span>(): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.join.php" class="methodname">join</a></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$glue</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.last.php" class="methodname">last</a></span>(): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.map.php" class="methodname">map</a></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type"><a href="class.ds-deque.php" class="type Ds\Deque">Ds\Deque</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.merge.php" class="methodname">merge</a></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$values</code></span>): <span class="type"><a href="class.ds-deque.php" class="type Ds\Deque">Ds\Deque</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.pop.php" class="methodname">pop</a></span>(): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.push.php" class="methodname">push</a></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">...$values</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.reduce.php" class="methodname">reduce</a></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$initial</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.remove.php" class="methodname">remove</a></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="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.reverse.php" class="methodname">reverse</a></span>(): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.reversed.php" class="methodname">reversed</a></span>(): <span class="type"><a href="class.ds-deque.php" class="type Ds\Deque">Ds\Deque</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.rotate.php" class="methodname">rotate</a></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$rotations</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.set.php" class="methodname">set</a></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.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.shift.php" class="methodname">shift</a></span>(): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.slice.php" class="methodname">slice</a></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>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.sort.php" class="methodname">sort</a></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$comparator</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.sorted.php" class="methodname">sorted</a></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$comparator</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="class.ds-deque.php" class="type Ds\Deque">Ds\Deque</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.sum.php" class="methodname">sum</a></span>(): <span class="type"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.float.php" class="type float">float</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.toarray.php" class="methodname">toArray</a></span>(): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="ds-deque.unshift.php" class="methodname">unshift</a></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$values</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

   }</div>


  </div>


  <div class="section" id="ds-deque.constants">
   <h2 class="title">Öntanımlı Sabitler</h2>
   <dl>

    
     <dt id="ds-deque.constants.min-capacity"><strong><code><a href="class.ds-deque.php#ds-deque.constants.min-capacity">Ds\Deque::MIN_CAPACITY</a></code></strong></dt>
     <dd>
      <p class="para"/>
     </dd>
    

   </dl>
  </div>


  <div class="section">
   <h2 class="title">Sürüm Bilgisi</h2>
   <p class="para">
    <table class="doctable informaltable">
     
      <thead>
       <tr>
        <th>Sürüm: </th>
        <th>Açıklama</th>
       </tr>

      </thead>

      <tbody class="tbody">
       <tr>
        <td>PECL ds 1.3.0</td>
        <td>
         The class now implements <span class="classname"><a href="class.arrayaccess.php" class="classname">ArrayAccess</a></span>.
        </td>
       </tr>

      </tbody>
     
    </table>

   </p>
  </div>

 </div>

 














































































































































































































































<h2>İçindekiler</h2><ul class="chunklist chunklist_reference"><li><a href="ds-deque.allocate.php">Ds\Deque::allocate</a> — Allocates enough memory for a required capacity</li><li><a href="ds-deque.apply.php">Ds\Deque::apply</a> — Updates all values by applying a callback function to each value</li><li><a href="ds-deque.capacity.php">Ds\Deque::capacity</a> — Returns the current capacity</li><li><a href="ds-deque.clear.php">Ds\Deque::clear</a> — Removes all values from the deque</li><li><a href="ds-deque.construct.php">Ds\Deque::__construct</a> — Creates a new instance</li><li><a href="ds-deque.contains.php">Ds\Deque::contains</a> — Determines if the deque contains given values</li><li><a href="ds-deque.copy.php">Ds\Deque::copy</a> — Returns a shallow copy of the deque</li><li><a href="ds-deque.count.php">Ds\Deque::count</a> — Returns the number of values in the collection</li><li><a href="ds-deque.filter.php">Ds\Deque::filter</a> — Creates a new deque using a callable to
    determine which values to include</li><li><a href="ds-deque.find.php">Ds\Deque::find</a> — Attempts to find a value's index</li><li><a href="ds-deque.first.php">Ds\Deque::first</a> — Returns the first value in the deque</li><li><a href="ds-deque.get.php">Ds\Deque::get</a> — Returns the value at a given index</li><li><a href="ds-deque.insert.php">Ds\Deque::insert</a> — Inserts values at a given index</li><li><a href="ds-deque.isempty.php">Ds\Deque::isEmpty</a> — Returns whether the deque is empty</li><li><a href="ds-deque.join.php">Ds\Deque::join</a> — Joins all values together as a string</li><li><a href="ds-deque.jsonserialize.php">Ds\Deque::jsonSerialize</a> — Returns a representation that can be converted to JSON</li><li><a href="ds-deque.last.php">Ds\Deque::last</a> — Returns the last value</li><li><a href="ds-deque.map.php">Ds\Deque::map</a> — Returns the result of applying a callback to each value</li><li><a href="ds-deque.merge.php">Ds\Deque::merge</a> — Returns the result of adding all given values to the deque</li><li><a href="ds-deque.pop.php">Ds\Deque::pop</a> — Removes and returns the last value</li><li><a href="ds-deque.push.php">Ds\Deque::push</a> — Adds values to the end of the deque</li><li><a href="ds-deque.reduce.php">Ds\Deque::reduce</a> — Reduces the deque to a single value using a callback function</li><li><a href="ds-deque.remove.php">Ds\Deque::remove</a> — Removes and returns a value by index</li><li><a href="ds-deque.reverse.php">Ds\Deque::reverse</a> — Reverses the deque in-place</li><li><a href="ds-deque.reversed.php">Ds\Deque::reversed</a> — Returns a reversed copy</li><li><a href="ds-deque.rotate.php">Ds\Deque::rotate</a> — Rotates the deque by a given number of rotations</li><li><a href="ds-deque.set.php">Ds\Deque::set</a> — Updates a value at a given index</li><li><a href="ds-deque.shift.php">Ds\Deque::shift</a> — Removes and returns the first value</li><li><a href="ds-deque.slice.php">Ds\Deque::slice</a> — Returns a sub-deque of a given range</li><li><a href="ds-deque.sort.php">Ds\Deque::sort</a> — Sorts the deque in-place</li><li><a href="ds-deque.sorted.php">Ds\Deque::sorted</a> — Returns a sorted copy</li><li><a href="ds-deque.sum.php">Ds\Deque::sum</a> — Returns the sum of all values in the deque</li><li><a href="ds-deque.toarray.php">Ds\Deque::toArray</a> — Converts the deque to an array</li><li><a href="ds-deque.unshift.php">Ds\Deque::unshift</a> — Adds values to the front of the deque</li></ul>
</div>
<?php manual_footer($setup); ?>