<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>HippoDraw Class Library</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="hippoApp.ico"> </head><body> <!-- Generated by Doxygen 1.6.2 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_d1aed8900ec9d9a2c165e57f18bd6f10.html">axes</a> </div> </div> <div class="contents"> <h1>Range.h</h1><a href="Range_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: c++ -*- */</span> <a name="l00002"></a>00002 <a name="l00014"></a>00014 <span class="preprocessor">#ifndef _RANGE_H_</span> <a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#define _RANGE_H_</span> <a name="l00016"></a>00016 <span class="preprocessor"></span> <a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="libhippo_8h.html">pattern/libhippo.h</a>"</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#include <vector></span> <a name="l00020"></a>00020 <a name="l00021"></a>00021 <span class="preprocessor">#include <cfloat></span> <span class="comment">// for DBL_MAX</span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="keyword">namespace </span>hippodraw { <a name="l00024"></a>00024 <a name="l00033"></a><a class="code" href="classhippodraw_1_1Range.html">00033</a> <span class="keyword">class </span><a class="code" href="libhippo_8h.html#a480024fd54849c743866874550153711">MDL_HIPPOPLOT_API</a> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> { <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="keyword">private</span>: <a name="l00036"></a>00036 <a name="l00039"></a><a class="code" href="classhippodraw_1_1Range.html#a373432986a680c846c5917927a926992">00039</a> <span class="keywordtype">double</span> m_min; <a name="l00040"></a>00040 <a name="l00043"></a><a class="code" href="classhippodraw_1_1Range.html#acf06000c1aa1991f025243b032b5dcad">00043</a> <span class="keywordtype">double</span> m_max; <a name="l00044"></a>00044 <a name="l00047"></a><a class="code" href="classhippodraw_1_1Range.html#a0f2dc708a2d9dc5aa37c32f2c36e734d">00047</a> <span class="keywordtype">double</span> m_pos; <a name="l00048"></a>00048 <a name="l00052"></a><a class="code" href="classhippodraw_1_1Range.html#ac21f18624d637a3e48f64730fb79c479">00052</a> <span class="keywordtype">bool</span> m_empty; <a name="l00053"></a>00053 <a name="l00054"></a>00054 <span class="keyword">public</span>: <a name="l00055"></a>00055 <a name="l00059"></a>00059 <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> ( ); <a name="l00060"></a>00060 <a name="l00064"></a>00064 <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> ( <span class="keywordtype">double</span> x, <a name="l00065"></a>00065 <span class="keywordtype">double</span> y, <a name="l00066"></a>00066 <span class="keywordtype">double</span> p = DBL_MAX ); <a name="l00067"></a>00067 <a name="l00071"></a>00071 <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> ( <span class="keyword">const</span> std::vector < double > & array ); <a name="l00072"></a>00072 <a name="l00075"></a>00075 <span class="keywordtype">double</span> low() <span class="keyword">const</span>; <a name="l00076"></a>00076 <a name="l00079"></a>00079 <span class="keywordtype">void</span> setLow(<span class="keywordtype">double</span> x); <a name="l00080"></a>00080 <a name="l00083"></a>00083 <span class="keywordtype">double</span> high() <span class="keyword">const</span>; <a name="l00084"></a>00084 <a name="l00087"></a>00087 <span class="keywordtype">void</span> setHigh(<span class="keywordtype">double</span> x); <a name="l00088"></a>00088 <a name="l00091"></a>00091 <span class="keywordtype">double</span> pos() <span class="keyword">const</span>; <a name="l00092"></a>00092 <a name="l00095"></a>00095 <span class="keywordtype">void</span> setPos(<span class="keywordtype">double</span> x); <a name="l00096"></a>00096 <a name="l00099"></a>00099 <span class="keywordtype">void</span> setRange ( <span class="keywordtype">double</span> low, <span class="keywordtype">double</span> high, <span class="keywordtype">double</span> pos ); <a name="l00100"></a>00100 <a name="l00103"></a>00103 <span class="keyword">template</span> < <span class="keyword">class</span> Iterator > <a name="l00104"></a>00104 <span class="keywordtype">void</span> setRange ( Iterator first, Iterator end ); <a name="l00105"></a>00105 <a name="l00108"></a>00108 <span class="keyword">inline</span> <span class="keywordtype">double</span> length() <span class="keyword">const</span>; <a name="l00109"></a>00109 <a name="l00113"></a>00113 <span class="keywordtype">void</span> setLength ( <span class="keywordtype">double</span> val, <span class="keywordtype">bool</span> high_hold = <span class="keyword">false</span> ); <a name="l00114"></a>00114 <a name="l00119"></a>00119 <span class="keywordtype">bool</span> includes ( <span class="keywordtype">double</span> value ) <span class="keyword">const</span>; <a name="l00120"></a>00120 <a name="l00125"></a>00125 <span class="keywordtype">bool</span> excludes ( <span class="keywordtype">double</span> value ) <span class="keyword">const</span>; <a name="l00126"></a>00126 <a name="l00129"></a>00129 <span class="keywordtype">double</span> fraction ( <span class="keywordtype">double</span> value ) <span class="keyword">const</span>; <a name="l00130"></a>00130 <a name="l00133"></a>00133 <span class="keywordtype">void</span> setIntersect ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & range ); <a name="l00134"></a>00134 <a name="l00140"></a>00140 <span class="keywordtype">void</span> setUnion ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & range ); <a name="l00141"></a>00141 <a name="l00144"></a>00144 <span class="keywordtype">void</span> setEmpty ( <span class="keywordtype">bool</span> yes = <span class="keyword">true</span> ); <a name="l00145"></a>00145 <a name="l00149"></a>00149 <span class="keywordtype">int</span> numberOfBins ( <span class="keywordtype">double</span> width ) <span class="keyword">const</span>; <a name="l00150"></a>00150 <a name="l00151"></a>00151 }; <a name="l00152"></a>00152 <a name="l00153"></a>00153 <span class="keyword">inline</span> <a name="l00154"></a>00154 <span class="keywordtype">double</span> <a name="l00155"></a>00155 <a class="code" href="classhippodraw_1_1Range.html#ad207cb443e371f73f07e874c504f60c1" title="Returns the length of the range object.">Range::</a> <a name="l00156"></a><a class="code" href="classhippodraw_1_1Range.html#ad207cb443e371f73f07e874c504f60c1">00156</a> <a class="code" href="classhippodraw_1_1Range.html#ad207cb443e371f73f07e874c504f60c1" title="Returns the length of the range object.">length</a> ()<span class="keyword"> const</span> <a name="l00157"></a>00157 <span class="keyword"></span>{ <a name="l00158"></a>00158 <span class="keywordflow">return</span> (<a class="code" href="classhippodraw_1_1Range.html#acf06000c1aa1991f025243b032b5dcad" title="The maximum in the range.">m_max</a> - <a class="code" href="classhippodraw_1_1Range.html#a373432986a680c846c5917927a926992" title="The minimum in the range.">m_min</a>); <a name="l00159"></a>00159 } <a name="l00160"></a>00160 <a name="l00161"></a>00161 <span class="keyword">template</span> < <span class="keyword">class</span> Iterator > <a name="l00162"></a>00162 <span class="keywordtype">void</span> <a name="l00163"></a>00163 <a class="code" href="classhippodraw_1_1Range.html#addffd7d4904f8f6261dae4e2cb51b734" title="Changes the current Range.">Range::</a> <a name="l00164"></a><a class="code" href="classhippodraw_1_1Range.html#afcecc44fcb3368d9cfda5d7ffdb0a81d">00164</a> <a class="code" href="classhippodraw_1_1Range.html#addffd7d4904f8f6261dae4e2cb51b734" title="Changes the current Range.">setRange</a> ( Iterator first, Iterator end ) <a name="l00165"></a>00165 { <a name="l00166"></a>00166 <a class="code" href="classhippodraw_1_1Range.html#a373432986a680c846c5917927a926992" title="The minimum in the range.">m_min</a> = DBL_MAX; <a name="l00167"></a>00167 <a class="code" href="classhippodraw_1_1Range.html#acf06000c1aa1991f025243b032b5dcad" title="The maximum in the range.">m_max</a> = -DBL_MAX; <a name="l00168"></a>00168 <a class="code" href="classhippodraw_1_1Range.html#a0f2dc708a2d9dc5aa37c32f2c36e734d" title="The minimum positive value in the range, for log scale.">m_pos</a> = DBL_MAX; <a name="l00169"></a>00169 <a name="l00170"></a>00170 <span class="keywordflow">while</span> ( first != end ) { <a name="l00171"></a>00171 <span class="keywordtype">double</span> test = *first; <span class="comment">// input might be pointer to float.</span> <a name="l00172"></a>00172 <a class="code" href="classhippodraw_1_1Range.html#a373432986a680c846c5917927a926992" title="The minimum in the range.">m_min</a> = std::min ( <a class="code" href="classhippodraw_1_1Range.html#a373432986a680c846c5917927a926992" title="The minimum in the range.">m_min</a>, test ); <a name="l00173"></a>00173 <a class="code" href="classhippodraw_1_1Range.html#acf06000c1aa1991f025243b032b5dcad" title="The maximum in the range.">m_max</a> = std::max ( <a class="code" href="classhippodraw_1_1Range.html#acf06000c1aa1991f025243b032b5dcad" title="The maximum in the range.">m_max</a>, test ); <a name="l00174"></a>00174 <span class="keywordflow">if</span> ( test > 0.0 ) <a class="code" href="classhippodraw_1_1Range.html#a0f2dc708a2d9dc5aa37c32f2c36e734d" title="The minimum positive value in the range, for log scale.">m_pos</a> = std::min ( <a class="code" href="classhippodraw_1_1Range.html#a0f2dc708a2d9dc5aa37c32f2c36e734d" title="The minimum positive value in the range, for log scale.">m_pos</a>, test ); <a name="l00175"></a>00175 ++first; <a name="l00176"></a>00176 } <a name="l00177"></a>00177 } <a name="l00178"></a>00178 <a name="l00179"></a>00179 } <span class="comment">// namespace hippodraw</span> <a name="l00180"></a>00180 <a name="l00181"></a>00181 <span class="preprocessor">#endif // _RANGE_H_</span> </pre></div></div> <hr size="1"><address style="align: right;"><small> Generated for HippoDraw Class Library by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0> </a> </small></address> </body> </html>