blob: c2689058f04cb78c17ea11a9760cc8269e509906 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>blocked_range.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li id="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
</ul></div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul></div>
<h1>blocked_range.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> Copyright 2005-2010 Intel Corporation. All Rights Reserved.</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment"> The source code contained or described herein and all documents related</span>
<a name="l00005"></a>00005 <span class="comment"> to the source code ("Material") are owned by Intel Corporation or its</span>
<a name="l00006"></a>00006 <span class="comment"> suppliers or licensors. Title to the Material remains with Intel</span>
<a name="l00007"></a>00007 <span class="comment"> Corporation or its suppliers and licensors. The Material is protected</span>
<a name="l00008"></a>00008 <span class="comment"> by worldwide copyright laws and treaty provisions. No part of the</span>
<a name="l00009"></a>00009 <span class="comment"> Material may be used, copied, reproduced, modified, published, uploaded,</span>
<a name="l00010"></a>00010 <span class="comment"> posted, transmitted, distributed, or disclosed in any way without</span>
<a name="l00011"></a>00011 <span class="comment"> Intel's prior express written permission.</span>
<a name="l00012"></a>00012 <span class="comment"></span>
<a name="l00013"></a>00013 <span class="comment"> No license under any patent, copyright, trade secret or other</span>
<a name="l00014"></a>00014 <span class="comment"> intellectual property right is granted to or conferred upon you by</span>
<a name="l00015"></a>00015 <span class="comment"> disclosure or delivery of the Materials, either expressly, by</span>
<a name="l00016"></a>00016 <span class="comment"> implication, inducement, estoppel or otherwise. Any license under such</span>
<a name="l00017"></a>00017 <span class="comment"> intellectual property rights must be express and approved by Intel in</span>
<a name="l00018"></a>00018 <span class="comment"> writing.</span>
<a name="l00019"></a>00019 <span class="comment">*/</span>
<a name="l00020"></a>00020
<a name="l00021"></a>00021 <span class="preprocessor">#ifndef __TBB_blocked_range_H</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#define __TBB_blocked_range_H</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "tbb_stddef.h"</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="keyword">namespace </span>tbb {
<a name="l00027"></a>00027
<a name="l00037"></a>00037
<a name="l00038"></a>00038
<a name="l00039"></a>00039 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Value&gt;
<a name="l00040"></a><a class="code" href="a00148.html">00040</a> <span class="keyword">class </span><a class="code" href="a00148.html">blocked_range</a> {
<a name="l00041"></a>00041 <span class="keyword">public</span>:
<a name="l00043"></a>00043
<a name="l00045"></a><a class="code" href="a00148.html#1a8d05842c2b3dfc177bc4d347e4cef7">00045</a> <span class="keyword">typedef</span> Value <a class="code" href="a00148.html#1a8d05842c2b3dfc177bc4d347e4cef7">const_iterator</a>;
<a name="l00046"></a>00046
<a name="l00048"></a><a class="code" href="a00148.html#f5707bffea38eee5c9680f37358afb8e">00048</a> <span class="keyword">typedef</span> std::size_t <a class="code" href="a00148.html#f5707bffea38eee5c9680f37358afb8e">size_type</a>;
<a name="l00049"></a>00049
<a name="l00051"></a>00051
<a name="l00052"></a><a class="code" href="a00148.html#94607755c5110d199202234d58d022ac">00052</a> <a class="code" href="a00148.html#94607755c5110d199202234d58d022ac">blocked_range</a>() : my_end(), my_begin() {}
<a name="l00053"></a>00053
<a name="l00055"></a><a class="code" href="a00148.html#14795a36ead1414b4371dbe1a4656359">00055</a> <a class="code" href="a00148.html#94607755c5110d199202234d58d022ac">blocked_range</a>( Value begin_, Value end_, <a class="code" href="a00148.html#f5707bffea38eee5c9680f37358afb8e">size_type</a> grainsize_=1 ) :
<a name="l00056"></a>00056 my_end(end_), my_begin(begin_), my_grainsize(grainsize_)
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058 __TBB_ASSERT( my_grainsize&gt;0, <span class="stringliteral">"grainsize must be positive"</span> );
<a name="l00059"></a>00059 }
<a name="l00060"></a>00060
<a name="l00062"></a><a class="code" href="a00148.html#18d2258400756ac1446dac7676b18df3">00062</a> <a class="code" href="a00148.html#1a8d05842c2b3dfc177bc4d347e4cef7">const_iterator</a> <a class="code" href="a00148.html#18d2258400756ac1446dac7676b18df3">begin</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> my_begin;}
<a name="l00063"></a>00063
<a name="l00065"></a><a class="code" href="a00148.html#8b929d93ddc13f148b11bceef3a3bdf8">00065</a> <a class="code" href="a00148.html#1a8d05842c2b3dfc177bc4d347e4cef7">const_iterator</a> <a class="code" href="a00148.html#8b929d93ddc13f148b11bceef3a3bdf8">end</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> my_end;}
<a name="l00066"></a>00066
<a name="l00068"></a>00068
<a name="l00069"></a><a class="code" href="a00148.html#9eaa0b6beff1420f688570bbf6b8c462">00069</a> <a class="code" href="a00148.html#f5707bffea38eee5c9680f37358afb8e">size_type</a> <a class="code" href="a00148.html#9eaa0b6beff1420f688570bbf6b8c462">size</a>()<span class="keyword"> const </span>{
<a name="l00070"></a>00070 __TBB_ASSERT( !(<a class="code" href="a00148.html#8b929d93ddc13f148b11bceef3a3bdf8">end</a>()&lt;<a class="code" href="a00148.html#18d2258400756ac1446dac7676b18df3">begin</a>()), <span class="stringliteral">"size() unspecified if end()&lt;begin()"</span> );
<a name="l00071"></a>00071 <span class="keywordflow">return</span> <a class="code" href="a00148.html#f5707bffea38eee5c9680f37358afb8e">size_type</a>(my_end-my_begin);
<a name="l00072"></a>00072 }
<a name="l00073"></a>00073
<a name="l00075"></a><a class="code" href="a00148.html#fcd2e5b8b6c11fd3f20fc0aa9f11bbc2">00075</a> <a class="code" href="a00148.html#f5707bffea38eee5c9680f37358afb8e">size_type</a> <a class="code" href="a00148.html#fcd2e5b8b6c11fd3f20fc0aa9f11bbc2">grainsize</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> my_grainsize;}
<a name="l00076"></a>00076
<a name="l00077"></a>00077 <span class="comment">//------------------------------------------------------------------------</span>
<a name="l00078"></a>00078 <span class="comment">// Methods that implement Range concept</span>
<a name="l00079"></a>00079 <span class="comment">//------------------------------------------------------------------------</span>
<a name="l00080"></a>00080
<a name="l00082"></a><a class="code" href="a00148.html#8f4f02f530eb3f2e7ea26e06f76aef9d">00082</a> <span class="keywordtype">bool</span> <a class="code" href="a00148.html#8f4f02f530eb3f2e7ea26e06f76aef9d">empty</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> !(my_begin&lt;my_end);}
<a name="l00083"></a>00083
<a name="l00085"></a>00085
<a name="l00086"></a><a class="code" href="a00148.html#41a58b703d574b6e1ca155df3576f578">00086</a> <span class="keywordtype">bool</span> <a class="code" href="a00148.html#41a58b703d574b6e1ca155df3576f578">is_divisible</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> my_grainsize&lt;<a class="code" href="a00148.html#9eaa0b6beff1420f688570bbf6b8c462">size</a>();}
<a name="l00087"></a>00087
<a name="l00089"></a>00089
<a name="l00091"></a><a class="code" href="a00148.html#4c0efd2be3f96a0ab3ba5085e8b3fcc7">00091</a> <a class="code" href="a00148.html#94607755c5110d199202234d58d022ac">blocked_range</a>( <a class="code" href="a00148.html">blocked_range</a>&amp; r, <a class="code" href="a00198.html">split</a> ) :
<a name="l00092"></a>00092 my_end(r.my_end),
<a name="l00093"></a>00093 my_begin(do_split(r)),
<a name="l00094"></a>00094 my_grainsize(r.my_grainsize)
<a name="l00095"></a>00095 {}
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="keyword">private</span>:
<a name="l00099"></a>00099 Value my_end;
<a name="l00100"></a>00100 Value my_begin;
<a name="l00101"></a>00101 <a class="code" href="a00148.html#f5707bffea38eee5c9680f37358afb8e">size_type</a> my_grainsize;
<a name="l00102"></a>00102
<a name="l00104"></a>00104
<a name="l00105"></a>00105 <span class="keyword">static</span> Value do_split( <a class="code" href="a00148.html">blocked_range</a>&amp; r ) {
<a name="l00106"></a>00106 __TBB_ASSERT( r.<a class="code" href="a00148.html#41a58b703d574b6e1ca155df3576f578">is_divisible</a>(), <span class="stringliteral">"cannot split blocked_range that is not divisible"</span> );
<a name="l00107"></a>00107 Value middle = r.<a class="code" href="a00148.html#e02559f817d8352c7bdf41dfddc53958">my_begin</a> + (r.<a class="code" href="a00148.html#1ec95c8988b50064dd603998b16f3930">my_end</a>-r.<a class="code" href="a00148.html#e02559f817d8352c7bdf41dfddc53958">my_begin</a>)/2u;
<a name="l00108"></a>00108 r.<a class="code" href="a00148.html#1ec95c8988b50064dd603998b16f3930">my_end</a> = middle;
<a name="l00109"></a>00109 <span class="keywordflow">return</span> middle;
<a name="l00110"></a>00110 }
<a name="l00111"></a>00111
<a name="l00112"></a>00112 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> RowValue, <span class="keyword">typename</span> ColValue&gt;
<a name="l00113"></a>00113 <span class="keyword">friend</span> <span class="keyword">class </span>blocked_range2d;
<a name="l00114"></a>00114
<a name="l00115"></a>00115 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> RowValue, <span class="keyword">typename</span> ColValue, <span class="keyword">typename</span> PageValue&gt;
<a name="l00116"></a>00116 <span class="keyword">friend</span> <span class="keyword">class </span>blocked_range3d;
<a name="l00117"></a>00117 };
<a name="l00118"></a>00118
<a name="l00119"></a>00119 } <span class="comment">// namespace tbb </span>
<a name="l00120"></a>00120
<a name="l00121"></a>00121 <span class="preprocessor">#endif </span><span class="comment">/* __TBB_blocked_range_H */</span>
</pre></div><hr>
<p></p>
Copyright &copy; 2005-2010 Intel Corporation. All Rights Reserved.
<p></p>
Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are
registered trademarks or trademarks of Intel Corporation or its
subsidiaries in the United States and other countries.
<p></p>
* Other names and brands may be claimed as the property of others.