From 534053f7c48fee934362034b46366bd30f7ad2ad Mon Sep 17 00:00:00 2001 From: realstealthninja Date: Sun, 17 Aug 2025 10:14:39 +0000 Subject: [PATCH] Documentation for 93c64b558a53f9e13a0573fe84da83c6e84c9dcb --- d1/d9e/prefix__sum__array_8cpp.html | 96 +++++++++++++--------- d1/d9e/prefix__sum__array_8cpp.js | 2 +- d1/d9e/prefix__sum__array_8cpp_source.html | 76 ++++++++--------- doxygen_crawl.html | 2 +- search/all_7.js | 2 +- search/functions_2.js | 2 +- 6 files changed, 102 insertions(+), 78 deletions(-) diff --git a/d1/d9e/prefix__sum__array_8cpp.html b/d1/d9e/prefix__sum__array_8cpp.html index 8c86818a2..152c3a324 100644 --- a/d1/d9e/prefix__sum__array_8cpp.html +++ b/d1/d9e/prefix__sum__array_8cpp.html @@ -139,16 +139,18 @@ Namespaces - - - + + +

Functions

-std::vector< int64_t > range_queries::prefix_sum_array::PSA (1, 0)
void range_queries::prefix_sum_array::build (std::vector< int64_t > original_array)
 function that builds the PSA
void range_queries::prefix_sum_array::build (const std::vector< int64_t > &original_array)
 function that builds the PSA
int64_t range_queries::prefix_sum_array::query (int64_t beg, int64_t end)
 query function
static void test ()
 Self-test implementations.
int main ()
 Main function.
+ +

+Variables

std::vector< int64_t > range_queries::prefix_sum_array::PSA {}

Detailed Description

Prefix Sum Array data structure implementation.

@@ -165,8 +167,8 @@ std::vector< int64_t > 

Definition in file prefix_sum_array.cpp.

Function Documentation

- -

◆ build()

+ +

◆ build()

@@ -174,7 +176,7 @@ std::vector< int64_t >  void range_queries::prefix_sum_array::build ( - std::vector< int64_t > original_array) + const std::vector< int64_t > & original_array) @@ -190,11 +192,13 @@ std::vector< int64_t > 
Returns
void

Definition at line 41 of file prefix_sum_array.cpp.

-
41 {
-
42 for (int i = 1; i <= static_cast<int>(original_array.size()); i++) {
-
43 PSA.push_back(PSA[i - 1] + original_array[i]);
-
44 }
-
45}
+
41 {
+
42 PSA.clear();
+
43 PSA.push_back(0);
+
44 for (std::size_t i = 1; i < original_array.size(); ++i) {
+
45 PSA.push_back(PSA.back() + original_array[i]);
+
46 }
+
47}
@@ -216,12 +220,12 @@ std::vector< int64_t > 

Main function.

Returns
0 on exit
-

Definition at line 80 of file prefix_sum_array.cpp.

-
80 {
-
81 test(); // run self-test implementations
-
82 return 0;
-
83}
-
static void test()
Self-test implementations.
+

Definition at line 82 of file prefix_sum_array.cpp.

+
82 {
+
83 test(); // run self-test implementations
+
84 return 0;
+
85}
+
static void test()
Self-test implementations.
@@ -254,8 +258,8 @@ std::vector< int64_t > 
Returns
sum of the range [beg, end]
-

Definition at line 52 of file prefix_sum_array.cpp.

-
52{ return PSA[end] - PSA[beg - 1]; }
+

Definition at line 54 of file prefix_sum_array.cpp.

+
54{ return PSA[end] - PSA[beg - 1]; }
@@ -285,23 +289,41 @@ std::vector< int64_t > 

Self-test implementations.

Returns
void
-

Definition at line 61 of file prefix_sum_array.cpp.

-
61 {
-
62 std::vector<int64_t> values{0, 123, 0, 2, -2, 5,
-
63 24, 0, 23, -1, -1}; // original array
-
64
- -
66 // queries are of the type: sum of the range [a, b] = psa[b] - psa[a-1]
-
67
- -
69 173); // sum of the entire array
- -
71 27); // the sum of the interval [4, 6]
- -
73 51); // the sum of the interval [5, 9]
-
74}
-
int64_t query(int64_t beg, int64_t end)
query function
-
void build(std::vector< int64_t > original_array)
function that builds the PSA
+

Definition at line 63 of file prefix_sum_array.cpp.

+
63 {
+
64 std::vector<int64_t> values{0, 123, 0, 2, -2, 5,
+
65 24, 0, 23, -1, -1}; // original array
+
66
+ +
68 // queries are of the type: sum of the range [a, b] = psa[b] - psa[a-1]
+
69
+ +
71 173); // sum of the entire array
+ +
73 27); // the sum of the interval [4, 6]
+ +
75 51); // the sum of the interval [5, 9]
+
76}
+
int64_t query(int64_t beg, int64_t end)
query function
+
void build(const std::vector< int64_t > &original_array)
function that builds the PSA
+
+
+ +

Variable Documentation

+ +

◆ PSA

+ +
+
+ + + + +
std::vector<int64_t> range_queries::prefix_sum_array::PSA {}
+
+ +

Definition at line 34 of file prefix_sum_array.cpp.

+
34{};
diff --git a/d1/d9e/prefix__sum__array_8cpp.js b/d1/d9e/prefix__sum__array_8cpp.js index 6b5243a15..c91314e85 100644 --- a/d1/d9e/prefix__sum__array_8cpp.js +++ b/d1/d9e/prefix__sum__array_8cpp.js @@ -1,6 +1,6 @@ var prefix__sum__array_8cpp = [ - [ "range_queries::prefix_sum_array::build", "d1/d9e/prefix__sum__array_8cpp.html#ab36151479ad37d53ef9fcb60a274b1d9", null ], + [ "range_queries::prefix_sum_array::build", "d1/d9e/prefix__sum__array_8cpp.html#a98e118ed64ba95a8198e1a915459c177", null ], [ "main", "d1/d9e/prefix__sum__array_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ], [ "range_queries::prefix_sum_array::query", "d1/d9e/prefix__sum__array_8cpp.html#a7c8fd967c36dbba5fdf9c71faed604cf", null ], [ "test", "d1/d9e/prefix__sum__array_8cpp.html#aa8dca7b867074164d5f45b0f3851269d", null ] diff --git a/d1/d9e/prefix__sum__array_8cpp_source.html b/d1/d9e/prefix__sum__array_8cpp_source.html index 4fc0b8f7d..76eb2908e 100644 --- a/d1/d9e/prefix__sum__array_8cpp_source.html +++ b/d1/d9e/prefix__sum__array_8cpp_source.html @@ -125,50 +125,52 @@ $(function(){initNavTree('d1/d9e/prefix__sum__array_8cpp_source.html','../../','
27namespace range_queries {
32namespace prefix_sum_array {
33
-
34std::vector<int64_t> PSA(1, 0);
+
34std::vector<int64_t> PSA{};
35
-
41void build(std::vector<int64_t> original_array) {
-
42 for (int i = 1; i <= static_cast<int>(original_array.size()); i++) {
-
43 PSA.push_back(PSA[i - 1] + original_array[i]);
-
44 }
-
45}
+
41void build(const std::vector<int64_t>& original_array) {
+
42 PSA.clear();
+
43 PSA.push_back(0);
+
44 for (std::size_t i = 1; i < original_array.size(); ++i) {
+
45 PSA.push_back(PSA.back() + original_array[i]);
+
46 }
+
47}
-
46
-
52int64_t query(int64_t beg, int64_t end) { return PSA[end] - PSA[beg - 1]; }
-
53
-
54} // namespace prefix_sum_array
-
55} // namespace range_queries
-
56
-
-
61static void test() {
-
62 std::vector<int64_t> values{0, 123, 0, 2, -2, 5,
-
63 24, 0, 23, -1, -1}; // original array
-
64
- -
66 // queries are of the type: sum of the range [a, b] = psa[b] - psa[a-1]
-
67
- -
69 173); // sum of the entire array
- -
71 27); // the sum of the interval [4, 6]
- -
73 51); // the sum of the interval [5, 9]
-
74}
+
48
+
54int64_t query(int64_t beg, int64_t end) { return PSA[end] - PSA[beg - 1]; }
+
55
+
56} // namespace prefix_sum_array
+
57} // namespace range_queries
+
58
+
+
63static void test() {
+
64 std::vector<int64_t> values{0, 123, 0, 2, -2, 5,
+
65 24, 0, 23, -1, -1}; // original array
+
66
+ +
68 // queries are of the type: sum of the range [a, b] = psa[b] - psa[a-1]
+
69
+ +
71 173); // sum of the entire array
+ +
73 27); // the sum of the interval [4, 6]
+ +
75 51); // the sum of the interval [5, 9]
+
76}
-
75
-
-
80int main() {
-
81 test(); // run self-test implementations
-
82 return 0;
-
83}
+
77
+
+
82int main() {
+
83 test(); // run self-test implementations
+
84 return 0;
+
85}
Range sum queries using prefix-sum-array.
for std::vector
-
int64_t query(int64_t beg, int64_t end)
query function
-
static void test()
Self-test implementations.
-
void build(std::vector< int64_t > original_array)
function that builds the PSA
-
int main()
Main function.
+
int64_t query(int64_t beg, int64_t end)
query function
+
void build(const std::vector< int64_t > &original_array)
function that builds the PSA
+
static void test()
Self-test implementations.
+
int main()
Main function.
diff --git a/doxygen_crawl.html b/doxygen_crawl.html index 811164b92..152a1c21b 100644 --- a/doxygen_crawl.html +++ b/doxygen_crawl.html @@ -279,8 +279,8 @@ + - diff --git a/search/all_7.js b/search/all_7.js index d9d94c57e..d0a61e3b1 100644 --- a/search/all_7.js +++ b/search/all_7.js @@ -69,7 +69,7 @@ var searchData= ['bubble_20sort_20algorithm_20analysis_20best_20case_20worst_20case_20average_20case_66',['Bubble Sort Algorithm Analysis (Best Case - Worst Case - Average Case)',['../d8/d13/bubble__sort_8cpp.html#autotoc_md111',1,'']]], ['bubble_5fsort_67',['bubble_sort',['../d0/dd5/namespacebubble__sort.html',1,'bubble_sort'],['../d8/d13/bubble__sort_8cpp.html#af3b12930a83915712461d53fe9659686',1,'sorting::bubble_sort::bubble_sort()']]], ['bubble_5fsort_2ecpp_68',['bubble_sort.cpp',['../d8/d13/bubble__sort_8cpp.html',1,'']]], - ['build_69',['build',['../d1/d9e/prefix__sum__array_8cpp.html#ab36151479ad37d53ef9fcb60a274b1d9',1,'range_queries::prefix_sum_array']]], + ['build_69',['build',['../d1/d9e/prefix__sum__array_8cpp.html#a98e118ed64ba95a8198e1a915459c177',1,'range_queries::prefix_sum_array']]], ['building_20locally_70',['Building Locally',['../d6/dcd/md__c_o_n_t_r_i_b_u_t_i_n_g.html#autotoc_md37',1,'']]], ['buzz_5fnumber_2ecpp_71',['buzz_number.cpp',['../d1/d76/buzz__number_8cpp.html',1,'']]] ]; diff --git a/search/functions_2.js b/search/functions_2.js index a2a4e7911..c4b7822cd 100644 --- a/search/functions_2.js +++ b/search/functions_2.js @@ -28,5 +28,5 @@ var searchData= ['brute_5fforce_25',['brute_force',['../d9/d03/namespacestring__search.html#aeb2cd81064717aedd62bfb096b1a73d8',1,'string_search::brute_force()'],['../d3/d7d/brute__force__string__searching_8cpp.html#aeb2cd81064717aedd62bfb096b1a73d8',1,'brute_force(): brute_force_string_searching.cpp']]], ['bst_5fnode_26',['bst_node',['../dd/db6/structbinary__search__tree_1_1bst__node.html#a51dd9bd6dd32bce3b74dd64557306778',1,'binary_search_tree::bst_node']]], ['bubble_5fsort_27',['bubble_sort',['../d8/d13/bubble__sort_8cpp.html#af3b12930a83915712461d53fe9659686',1,'sorting::bubble_sort']]], - ['build_28',['build',['../d1/d9e/prefix__sum__array_8cpp.html#ab36151479ad37d53ef9fcb60a274b1d9',1,'range_queries::prefix_sum_array']]] + ['build_28',['build',['../d1/d9e/prefix__sum__array_8cpp.html#a98e118ed64ba95a8198e1a915459c177',1,'range_queries::prefix_sum_array']]] ];