<divclass="center"><iframescrolling="no"frameborder="0"src="../../d6/ddc/segment__tree_8c__incl.svg"width="448"height="124"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<trclass="memdesc:"><tdclass="mdescLeft"> </td><tdclass="mdescRight">This structures holds all the data that is required by a segment tree. <ahref="../../dd/d06/structsegment__tree.html#details">More...</a><br/></td></tr>
<trclass="memdesc:aca549b5311d32ab1a703b4a4605821d8"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Function that combines two data to generate a new one The name of function might be misleading actually combine here signifies the fact that in segment trees we take partial result from two ranges and using partial results we derive the result for joint range of those two ranges For Example: array(1,2,3,4,5,6) sum of range [0,2] = 6 and sum of range [3,5] = 15 the combined sum of two range is 6+15=21. <ahref="../../da/da0/segment__tree_8c.html#aca549b5311d32ab1a703b4a4605821d8">More...</a><br/></td></tr>
<trclass="memdesc:ac206721972f739510cb11f7c0a6a8f63"><tdclass="mdescLeft"> </td><tdclass="mdescRight">This structures holds all the data that is required by a segment tree. <br/></td></tr>
<trclass="memdesc:aae59daf9a0dc33f8cbc7a525a616ee75"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Builds a Segment tree It is assumed that leaves of tree already contains data. <ahref="../../da/da0/segment__tree_8c.html#aae59daf9a0dc33f8cbc7a525a616ee75">More...</a><br/></td></tr>
<trclass="memdesc:a1e81a9bbf01716f1b4fb27ef36a9098c"><tdclass="mdescLeft"> </td><tdclass="mdescRight">For point updates This function updates the element at given index and also updates segment tree accordingly. <ahref="../../da/da0/segment__tree_8c.html#a1e81a9bbf01716f1b4fb27ef36a9098c">More...</a><br/></td></tr>
<trclass="memitem:af61bd96660cb53f49f28d60a5f1d0c91"><tdclass="memItemLeft"align="right"valign="top">void </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="../../da/da0/segment__tree_8c.html#af61bd96660cb53f49f28d60a5f1d0c91">segment_tree_query</a> (<aclass="el"href="../../dd/d06/structsegment__tree.html">segment_tree</a> *tree, long long l, long long r, void *res)</td></tr>
<trclass="memdesc:af61bd96660cb53f49f28d60a5f1d0c91"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Query the segment tree This function helps in range query of segment tree This function assumes that the given range is valid Performs the query in range [l,r]. <ahref="../../da/da0/segment__tree_8c.html#af61bd96660cb53f49f28d60a5f1d0c91">More...</a><br/></td></tr>
<trclass="memdesc:a3513a2b7c3f1d15aa3d019af1f834cde"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Initializes Segment Tree Accquires memory for segment tree and fill the leaves of segment tree with data from array. <ahref="../../da/da0/segment__tree_8c.html#a3513a2b7c3f1d15aa3d019af1f834cde">More...</a><br/></td></tr>
<trclass="memdesc:af20a9f373083d3f701e1cd92560cef01"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Dispose Segment Tree Frees all heap memory accquired by segment tree. <ahref="../../da/da0/segment__tree_8c.html#af20a9f373083d3f701e1cd92560cef01">More...</a><br/></td></tr>
<trclass="memdesc:a776abfa81cde9016a2885dca7cfc05ab"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Prints the data in segment tree The data should be of int type A utility to print segment tree with data type of int. <ahref="../../da/da0/segment__tree_8c.html#a776abfa81cde9016a2885dca7cfc05ab">More...</a><br/></td></tr>
<trclass="memdesc:a93bfab032ce9dbc0c1feaeee32a885fb"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Utility for test A function compare for minimum between two integers This function is used as combine_function for RMQ. <ahref="../../da/da0/segment__tree_8c.html#a93bfab032ce9dbc0c1feaeee32a885fb">More...</a><br/></td></tr>
<trclass="memdesc:aa8dca7b867074164d5f45b0f3851269d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Test RMQ Testing Segment tree using Range Minimum Queries. <ahref="../../da/da0/segment__tree_8c.html#aa8dca7b867074164d5f45b0f3851269d">More...</a><br/></td></tr>
<divclass="textblock"><p>segment trees with only point updates </p>
<p>This code implements segment trees. Segment trees are general structures which allow range based queries in a given array in logN time. Segment tree with point updates allow update of single element in the array in logN time. <ahref="https://codeforces.com/blog/entry/18051"target="_blank">Learn more about segment trees here</a></p><dlclass="section author"><dt>Author</dt><dd><ahref="https://github.com/Lakhan-Nad"target="_blank">Lakhan Nad</a></dd></dl>
<p>Function that combines two data to generate a new one The name of function might be misleading actually combine here signifies the fact that in segment trees we take partial result from two ranges and using partial results we derive the result for joint range of those two ranges For Example: array(1,2,3,4,5,6) sum of range [0,2] = 6 and sum of range [3,5] = 15 the combined sum of two range is 6+15=21. </p>
<dlclass="section note"><dt>Note</dt><dd>The function is same to binary function in Discrete Mathematics </dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">a</td><td>pointer to first data </td></tr>
<tr><tdclass="paramname">b</td><td>pointer to second data </td></tr>
<tr><tdclass="paramname">result</td><td>pointer to memory location where result of combining a and b is to be stored </td></tr>
<divclass="ttc"id="asegment__tree_8c_html_aa8dca7b867074164d5f45b0f3851269d"><divclass="ttname"><ahref="../../da/da0/segment__tree_8c.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><divclass="ttdeci">static void test()</div><divclass="ttdoc">Test RMQ Testing Segment tree using Range Minimum Queries.</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:205</div></div>
<divclass="center"><iframescrolling="no"frameborder="0"src="../../da/da0/segment__tree_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg"width="450"height="283"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<divclass="ttc"id="astructsegment__tree_html_a5ad61abcbd2c25a4a71416281dba8f1e"><divclass="ttname"><ahref="../../dd/d06/structsegment__tree.html#a5ad61abcbd2c25a4a71416281dba8f1e">segment_tree::length</a></div><divclass="ttdeci">size_t length</div><divclass="ttdoc">total size of array which segment tree represents</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:43</div></div>
<divclass="ttc"id="astructsegment__tree_html_a973ab017a97678fdc6774543585897df"><divclass="ttname"><ahref="../../dd/d06/structsegment__tree.html#a973ab017a97678fdc6774543585897df">segment_tree::combine</a></div><divclass="ttdeci">combine_function combine</div><divclass="ttdoc">the function to be used to combine two node's data to form parent's data</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:47</div></div>
<divclass="ttc"id="astructsegment__tree_html_aa18d7cb422873a807707b26448dce7cd"><divclass="ttname"><ahref="../../dd/d06/structsegment__tree.html#aa18d7cb422873a807707b26448dce7cd">segment_tree::root</a></div><divclass="ttdeci">void * root</div><divclass="ttdoc">the root of formed segment tree</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:40</div></div>
<divclass="ttc"id="astructsegment__tree_html_aa9dc376b5b219c4cec6546483527b853"><divclass="ttname"><ahref="../../dd/d06/structsegment__tree.html#aa9dc376b5b219c4cec6546483527b853">segment_tree::elem_size</a></div><divclass="ttdeci">size_t elem_size</div><divclass="ttdoc">size in bytes of each data element</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:42</div></div>
<divclass="ttc"id="amalloc__dbg_8h_html_a9cc854374299a1dd933bf62029761768"><divclass="ttname"><ahref="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a></div><divclass="ttdeci">#define free(ptr)</div><divclass="ttdoc">This macro replace the standard free function with free_dbg.</div><divclass="ttdef"><b>Definition:</b> malloc_dbg.h:26</div></div>
<divclass="ttc"id="astructsegment__tree_html_a5373ee53a5ac1cd7a9dcb89a4c23a04a"><divclass="ttname"><ahref="../../dd/d06/structsegment__tree.html#a5373ee53a5ac1cd7a9dcb89a4c23a04a">segment_tree::identity</a></div><divclass="ttdeci">void * identity</div><divclass="ttdoc">identity element for combine function</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:41</div></div>
<divclass="ttc"id="aclient_8c_html_ac17020a38607ab29ce18939d5194a32a"><divclass="ttname"><ahref="../../dd/d93/client_8c.html#ac17020a38607ab29ce18939d5194a32a">func</a></div><divclass="ttdeci">void func(int sockfd)</div><divclass="ttdoc">Continuous loop to send and receive over the socket.</div><divclass="ttdef"><b>Definition:</b> client.c:37</div></div>
<divclass="ttc"id="amalloc__dbg_8h_html_a725f50ecaf1959d96de79b36b4788fee"><divclass="ttname"><ahref="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a></div><divclass="ttdeci">#define malloc(bytes)</div><divclass="ttdoc">This macro replace the standard malloc function with malloc_dbg.</div><divclass="ttdef"><b>Definition:</b> malloc_dbg.h:18</div></div>
<divclass="ttc"id="astructsegment__tree_html"><divclass="ttname"><ahref="../../dd/d06/structsegment__tree.html">segment_tree</a></div><divclass="ttdoc">This structures holds all the data that is required by a segment tree.</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:39</div></div>
<divclass="center"><iframescrolling="no"frameborder="0"src="../../da/da0/segment__tree_8c_a3513a2b7c3f1d15aa3d019af1f834cde_cgraph.svg"width="231"height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<p>Query the segment tree This function helps in range query of segment tree This function assumes that the given range is valid Performs the query in range [l,r]. </p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">tree</td><td>pointer to segment tree </td></tr>
<tr><tdclass="paramname">l</td><td>the start of range </td></tr>
<tr><tdclass="paramname">r</td><td>the end of range </td></tr>
<tr><tdclass="paramname">res</td><td>the pointer to memory where result of query is stored </td></tr>
<divclass="line"><spanclass="lineno"> 82</span> index = index + tree-><aclass="code hl_variable"href="../../dd/d06/structsegment__tree.html#a5ad61abcbd2c25a4a71416281dba8f1e">length</a> - 1;</div>
<divclass="ttc"id="asegment__tree_8c_html_a1e81a9bbf01716f1b4fb27ef36a9098c"><divclass="ttname"><ahref="../../da/da0/segment__tree_8c.html#a1e81a9bbf01716f1b4fb27ef36a9098c">segment_tree_update</a></div><divclass="ttdeci">void segment_tree_update(segment_tree *tree, size_t index, void *val)</div><divclass="ttdoc">For point updates This function updates the element at given index and also updates segment tree acco...</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:79</div></div>
<divclass="ttc"id="asegment__tree_8c_html_a3513a2b7c3f1d15aa3d019af1f834cde"><divclass="ttname"><ahref="../../da/da0/segment__tree_8c.html#a3513a2b7c3f1d15aa3d019af1f834cde">segment_tree_init</a></div><divclass="ttdeci">segment_tree * segment_tree_init(void *arr, size_t elem_size, size_t len, void *identity, combine_function func)</div><divclass="ttdoc">Initializes Segment Tree Accquires memory for segment tree and fill the leaves of segment tree with d...</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:140</div></div>
<divclass="ttc"id="asegment__tree_8c_html_a93bfab032ce9dbc0c1feaeee32a885fb"><divclass="ttname"><ahref="../../da/da0/segment__tree_8c.html#a93bfab032ce9dbc0c1feaeee32a885fb">minimum</a></div><divclass="ttdeci">void minimum(const void *a, const void *b, void *c)</div><divclass="ttdoc">Utility for test A function compare for minimum between two integers This function is used as combine...</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:194</div></div>
<divclass="ttc"id="asegment__tree_8c_html_aae59daf9a0dc33f8cbc7a525a616ee75"><divclass="ttname"><ahref="../../da/da0/segment__tree_8c.html#aae59daf9a0dc33f8cbc7a525a616ee75">segment_tree_build</a></div><divclass="ttdeci">void segment_tree_build(segment_tree *tree)</div><divclass="ttdoc">Builds a Segment tree It is assumed that leaves of tree already contains data.</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:55</div></div>
<divclass="ttc"id="asegment__tree_8c_html_af20a9f373083d3f701e1cd92560cef01"><divclass="ttname"><ahref="../../da/da0/segment__tree_8c.html#af20a9f373083d3f701e1cd92560cef01">segment_tree_dispose</a></div><divclass="ttdeci">void segment_tree_dispose(segment_tree *tree)</div><divclass="ttdoc">Dispose Segment Tree Frees all heap memory accquired by segment tree.</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:162</div></div>
<divclass="ttc"id="asegment__tree_8c_html_af61bd96660cb53f49f28d60a5f1d0c91"><divclass="ttname"><ahref="../../da/da0/segment__tree_8c.html#af61bd96660cb53f49f28d60a5f1d0c91">segment_tree_query</a></div><divclass="ttdeci">void segment_tree_query(segment_tree *tree, long long l, long long r, void *res)</div><divclass="ttdoc">Query the segment tree This function helps in range query of segment tree This function assumes that ...</div><divclass="ttdef"><b>Definition:</b> segment_tree.c:105</div></div>
<divclass="center"><iframescrolling="no"frameborder="0"src="../../da/da0/segment__tree_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg"width="351"height="283"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<liclass="footer">Generated by <ahref="https://www.doxygen.org/index.html"><imgclass="footer"src="../../doxygen.svg"width="104"height="31"alt="doxygen"/></a> 1.9.5 </li>