Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 1939

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Allocates enough memory for a required capacity</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ds-set.add.html">Ds\Set::add</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ds-set.capacity.html">Ds\Set::capacity</a></div>
 <div class="up"><a href="class.ds-set.html">Set</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="ds-set.allocate" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Ds\Set::allocate</h1>
  <p class="verinfo">(PECL ds &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Ds\Set::allocate</span> &mdash; <span class="dc-title">Allocates enough memory for a required capacity</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-ds-set.allocate-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>Ds\Set::allocate</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$capacity</code></span>
   )</div>

  <p class="para rdfs-comment">
    Allocates enough memory for a required capacity.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-ds-set.allocate-parameters">
  <h3 class="title">Parameters</h3>
  <dl>

   
    <dt>
<code class="parameter">capacity</code></dt>

    <dd>

     <p class="para">
        The number of values for which capacity should be allocated.
     </p>
     <blockquote class="note"><p><strong class="note">Note</strong>: 
        <p class="para">
            Capacity will stay the same if this value is less than or equal to the
            current capacity.
        </p>
     </p></blockquote>
     <blockquote class="note"><p><strong class="note">Note</strong>: 
        <p class="para">
            Capacity will always be rounded up to the nearest power of 2.
        </p>
     </p></blockquote>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-ds-set.allocate-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
    No value is returned.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-ds-set.allocate-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-5300">
   <p><strong>Example #1 <span class="function"><strong>Ds\Set::allocate()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$set&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;\</span><span style="color: #0000BB">Ds</span><span style="color: #007700">\</span><span style="color: #0000BB">Set</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$set</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">capacity</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">$set</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">allocate</span><span style="color: #007700">(</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$set</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">capacity</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above example will output
something similar to:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
int(16)
int(128)
</pre></div>
   </div>
  </div>
 </div>



</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ds-set.add.html">Ds\Set::add</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ds-set.capacity.html">Ds\Set::capacity</a></div>
 <div class="up"><a href="class.ds-set.html">Set</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>