From 03bb1302aa9d0ea59e57b536d104427f110407fb Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Wed, 12 Oct 2022 14:52:19 +0000 Subject: [PATCH] Documentation for 8241a58d42afaad3f326b0c14e651aeb83864d60 --- d1/dc7/run__length__encoding_8c.html | 297 ++++++++++++++++++ d1/dc7/run__length__encoding_8c.js | 6 + ...8dca7b867074164d5f45b0f3851269d_cgraph.map | 4 + ...8dca7b867074164d5f45b0f3851269d_cgraph.md5 | 1 + ...8dca7b867074164d5f45b0f3851269d_cgraph.svg | 42 +++ ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map | 5 + ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 | 1 + ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg | 57 ++++ d5/d88/md__d_i_r_e_c_t_o_r_y.html | 1 + dc/dcb/run__length__encoding_8c__incl.map | 7 + dc/dcb/run__length__encoding_8c__incl.md5 | 1 + dc/dcb/run__length__encoding_8c__incl.svg | 81 +++++ dir_a52f4d3d586a58b02f3a4ddf0a992157.html | 3 + dir_a52f4d3d586a58b02f3a4ddf0a992157.js | 1 + files.html | 7 +- globals_func_m.html | 2 +- globals_func_r.html | 1 + globals_func_t.html | 2 +- globals_m.html | 2 +- globals_r.html | 1 + globals_t.html | 2 +- navtreedata.js | 6 +- navtreeindex0.js | 10 +- navtreeindex1.js | 18 +- navtreeindex2.js | 10 +- navtreeindex3.js | 20 +- search/all_14.js | 4 +- search/all_16.js | 4 +- search/all_f.js | 2 +- search/files_12.js | 3 +- search/functions_12.js | 3 +- search/functions_14.js | 2 +- search/functions_d.js | 2 +- 33 files changed, 563 insertions(+), 45 deletions(-) create mode 100644 d1/dc7/run__length__encoding_8c.html create mode 100644 d1/dc7/run__length__encoding_8c.js create mode 100644 d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.map create mode 100644 d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 create mode 100644 d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg create mode 100644 d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map create mode 100644 d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 create mode 100644 d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg create mode 100644 dc/dcb/run__length__encoding_8c__incl.map create mode 100644 dc/dcb/run__length__encoding_8c__incl.md5 create mode 100644 dc/dcb/run__length__encoding_8c__incl.svg diff --git a/d1/dc7/run__length__encoding_8c.html b/d1/dc7/run__length__encoding_8c.html new file mode 100644 index 00000000..139d3e0b --- /dev/null +++ b/d1/dc7/run__length__encoding_8c.html @@ -0,0 +1,297 @@ + + + + + + + +Algorithms_in_C: misc/run_length_encoding.c File Reference + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C 1.0.0 +
+
Set of algorithms implemented in C.
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
run_length_encoding.c File Reference
+
+
+ +

Encode a null terminated string using Run-length encoding +More...

+
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+Include dependency graph for run_length_encoding.c:
+
+
+
+
+
+ + + + + + + + + + +

+Functions

char * run_length_encode (char *str)
 for IO operations More...
 
static void test ()
 Self-test implementations. More...
 
int main ()
 Main function. More...
 
+

Detailed Description

+

Encode a null terminated string using Run-length encoding

+
Author
serturx
+

Run-length encoding is a lossless compression algorithm. It works by counting the consecutive occurences symbols and encodes that series of consecutive symbols into the counted symbol and a number denoting the number of consecutive occorences.

+

For example the string "AAAABBCCD" gets encoded into "4A2B2C1D"

+

Function Documentation

+ +

◆ main()

+ +
+
+ + + + + + + + +
int main (void )
+
+ +

Main function.

+
Returns
0 on exit
+
88 {
+
89 test(); // run self-test implementations
+
90 printf("All tests have passed!\n");
+
91 return 0;
+
92}
+
static void test()
Self-test implementations.
Definition: run_length_encoding.c:71
+
+Here is the call graph for this function:
+
+
+
+
+ +
+
+ +

◆ run_length_encode()

+ +
+
+ + + + + + + + +
char * run_length_encode (char * str)
+
+ +

for IO operations

+

for string functions for malloc/free for assert

+

Encodes a null-terminated string using run-length encoding

Parameters
+ + +
strString to encode
+
+
+
Returns
char* Encoded string
+
27 {
+
28 int str_length = strlen(str);
+
29 int encoded_index = 0;
+
30
+
31 //allocate space for worst-case scenario
+
32 char* encoded = malloc(2 * strlen(str));
+
33
+
34 //temp space for int to str conversion
+
35 char int_str[20];
+
36
+
37 for(int i = 0; i < str_length; ++i) {
+
38 int count = 0;
+
39 char current = str[i];
+
40
+
41 //count occurences
+
42 while(current == str[i + count]) count++;
+
43
+
44 i += count - 1;
+
45
+
46 //convert occurrence amount to string and write to encoded string
+
47 sprintf(int_str, "%d", count);
+
48 int int_str_length = strlen(int_str);
+
49 strncpy(&encoded[encoded_index], int_str, strlen(int_str));
+
50
+
51 //write current char to encoded string
+
52 encoded_index += strlen(int_str);
+
53 encoded[encoded_index] = current;
+
54 ++encoded_index;
+
55 }
+
56
+
57 //null terminate string and move encoded string to compacted memory space
+
58 encoded[encoded_index] = '\0';
+
59 char* compacted_string = malloc(strlen(encoded) + 1);
+
60 strcpy(compacted_string, encoded);
+
61
+
62 free(encoded);
+
63
+
64 return compacted_string;
+
65}
+
#define malloc(bytes)
This macro replace the standard malloc function with malloc_dbg.
Definition: malloc_dbg.h:18
+
#define free(ptr)
This macro replace the standard free function with free_dbg.
Definition: malloc_dbg.h:26
+
+
+
+ +

◆ test()

+ +
+
+ + + + + +
+ + + + + + + + +
static void test (void )
+
+static
+
+ +

Self-test implementations.

+
Returns
void
+
71 {
+
72 char* test;
+
73 test = run_length_encode("aaaaaaabbbaaccccdefaadr");
+
74 assert(!strcmp(test, "7a3b2a4c1d1e1f2a1d1r"));
+
75 free(test);
+
76 test = run_length_encode("lidjhvipdurevbeirbgipeahapoeuhwaipefupwieofb");
+
77 assert(!strcmp(test, "1l1i1d1j1h1v1i1p1d1u1r1e1v1b1e1i1r1b1g1i1p1e1a1h1a1p1o1e1u1h1w1a1i1p1e1f1u1p1w1i1e1o1f1bq"));
+
78 free(test);
+
79 test = run_length_encode("htuuuurwuquququuuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahghghrw");
+
80 assert(!strcmp(test, "1h1t4u1r1w1u1q1u1q1u1q3u76a1h1g1h1g1h1r1w"));
+
81 free(test);
+
82}
+
char * run_length_encode(char *str)
for IO operations
Definition: run_length_encoding.c:27
+
+Here is the call graph for this function:
+
+
+
+
+ +
+
+
+
+ + + + diff --git a/d1/dc7/run__length__encoding_8c.js b/d1/dc7/run__length__encoding_8c.js new file mode 100644 index 00000000..9b6305c1 --- /dev/null +++ b/d1/dc7/run__length__encoding_8c.js @@ -0,0 +1,6 @@ +var run__length__encoding_8c = +[ + [ "main", "d1/dc7/run__length__encoding_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ], + [ "run_length_encode", "d1/dc7/run__length__encoding_8c.html#ac3cc4a63cf2a14a08e05c5537ecf59c2", null ], + [ "test", "d1/dc7/run__length__encoding_8c.html#aa8dca7b867074164d5f45b0f3851269d", null ] +]; \ No newline at end of file diff --git a/d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.map new file mode 100644 index 00000000..1bef27d1 --- /dev/null +++ b/d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.map @@ -0,0 +1,4 @@ + + + + diff --git a/d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 new file mode 100644 index 00000000..f67feaa2 --- /dev/null +++ b/d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 @@ -0,0 +1 @@ +91cbdddb50cfd1b9b4def06a8b2fe4e9 \ No newline at end of file diff --git a/d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg new file mode 100644 index 00000000..4137b49d --- /dev/null +++ b/d1/dc7/run__length__encoding_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg @@ -0,0 +1,42 @@ + + + + + + +test + + +Node1 + + +test + + + + + +Node1->Node1 + + + + + +Node2 + + +run_length_encode + + + + + +Node1->Node2 + + + + + diff --git a/d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map new file mode 100644 index 00000000..158818a7 --- /dev/null +++ b/d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 new file mode 100644 index 00000000..46aebdee --- /dev/null +++ b/d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -0,0 +1 @@ +e1a3cc88be1b7b50a8ea7251b49d9a38 \ No newline at end of file diff --git a/d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg new file mode 100644 index 00000000..0eceeccc --- /dev/null +++ b/d1/dc7/run__length__encoding_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -0,0 +1,57 @@ + + + + + + +main + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + +Node2->Node2 + + + + + +Node3 + + +run_length_encode + + + + + +Node2->Node3 + + + + + diff --git a/d5/d88/md__d_i_r_e_c_t_o_r_y.html b/d5/d88/md__d_i_r_e_c_t_o_r_y.html index ebbeae7c..585d7e17 100644 --- a/d5/d88/md__d_i_r_e_c_t_o_r_y.html +++ b/d5/d88/md__d_i_r_e_c_t_o_r_y.html @@ -451,6 +451,7 @@ Misc
  • Prime Seive
  • Quartile
  • Rselect
  • +
  • Run Length Encoding
  • Strong Number
  • Sudoku Solver
  • Tower Of Hanoi
  • diff --git a/dc/dcb/run__length__encoding_8c__incl.map b/dc/dcb/run__length__encoding_8c__incl.map new file mode 100644 index 00000000..5860c1d6 --- /dev/null +++ b/dc/dcb/run__length__encoding_8c__incl.map @@ -0,0 +1,7 @@ + + + + + + + diff --git a/dc/dcb/run__length__encoding_8c__incl.md5 b/dc/dcb/run__length__encoding_8c__incl.md5 new file mode 100644 index 00000000..6d664f30 --- /dev/null +++ b/dc/dcb/run__length__encoding_8c__incl.md5 @@ -0,0 +1 @@ +23565b917d74047a8b007414a44ad148 \ No newline at end of file diff --git a/dc/dcb/run__length__encoding_8c__incl.svg b/dc/dcb/run__length__encoding_8c__incl.svg new file mode 100644 index 00000000..5b1e22f3 --- /dev/null +++ b/dc/dcb/run__length__encoding_8c__incl.svg @@ -0,0 +1,81 @@ + + + + + + +misc/run_length_encoding.c + + +Node1 + + +misc/run_length_encoding.c + + + + + +Node2 + + +stdio.h + + + + + +Node1->Node2 + + + + + +Node3 + + +string.h + + + + + +Node1->Node3 + + + + + +Node4 + + +stdlib.h + + + + + +Node1->Node4 + + + + + +Node5 + + +assert.h + + + + + +Node1->Node5 + + + + + diff --git a/dir_a52f4d3d586a58b02f3a4ddf0a992157.html b/dir_a52f4d3d586a58b02f3a4ddf0a992157.html index 49e75e84..9cbd2499 100644 --- a/dir_a52f4d3d586a58b02f3a4ddf0a992157.html +++ b/dir_a52f4d3d586a58b02f3a4ddf0a992157.html @@ -136,6 +136,9 @@ Files file  prime_seive.c  Prime Seive algorithm implementation.
      +file  run_length_encoding.c + Encode a null terminated string using Run-length encoding
    +  file  strong_number.c  Strong number is a number whose sum of all digits’ factorial is equal to the number n For example: 145 = 1!(1) + 4!(24) + 5!(120)
      diff --git a/dir_a52f4d3d586a58b02f3a4ddf0a992157.js b/dir_a52f4d3d586a58b02f3a4ddf0a992157.js index f2cf166f..fe3d97ed 100644 --- a/dir_a52f4d3d586a58b02f3a4ddf0a992157.js +++ b/dir_a52f4d3d586a58b02f3a4ddf0a992157.js @@ -11,6 +11,7 @@ var dir_a52f4d3d586a58b02f3a4ddf0a992157 = [ "postfix_evaluation.c", "df/d43/postfix__evaluation_8c.html", "df/d43/postfix__evaluation_8c" ], [ "prime.c", "da/d93/prime_8c.html", "da/d93/prime_8c" ], [ "prime_seive.c", "db/dd5/prime__seive_8c.html", "db/dd5/prime__seive_8c" ], + [ "run_length_encoding.c", "d1/dc7/run__length__encoding_8c.html", "d1/dc7/run__length__encoding_8c" ], [ "strong_number.c", "d4/dcc/strong__number_8c.html", "d4/dcc/strong__number_8c" ], [ "sudoku_solver.c", "de/dac/sudoku__solver_8c.html", "de/dac/sudoku__solver_8c" ], [ "union_find.c", "df/df3/union__find_8c.html", "df/df3/union__find_8c" ] diff --git a/files.html b/files.html index 89294849..9bff89f7 100644 --- a/files.html +++ b/files.html @@ -204,9 +204,10 @@ $(document).ready(function(){initNavTree('files.html',''); initResizable(); });  postfix_evaluation.cPostfix evaluation algorithm implementation  prime.cProgram to identify if a number is prime number or not  prime_seive.cPrime Seive algorithm implementation - strong_number.cStrong number is a number whose sum of all digits’ factorial is equal to the number n For example: 145 = 1!(1) + 4!(24) + 5!(120) - sudoku_solver.cSudoku Solver using recursive implementation of brute-force algorithm - union_find.cUnion find algorithm + run_length_encoding.cEncode a null terminated string using Run-length encoding + strong_number.cStrong number is a number whose sum of all digits’ factorial is equal to the number n For example: 145 = 1!(1) + 4!(24) + 5!(120) + sudoku_solver.cSudoku Solver using recursive implementation of brute-force algorithm + union_find.cUnion find algorithm   numerical_methods  durand_kerner_roots.cCompute all possible approximate roots of any given polynomial using Durand Kerner algorithm  lu_decompose.cLU decomposition of a square matrix diff --git a/globals_func_m.html b/globals_func_m.html index 7cdf8542..b958624e 100644 --- a/globals_func_m.html +++ b/globals_func_m.html @@ -100,7 +100,7 @@ $(document).ready(function(){initNavTree('globals_func_m.html',''); initResizabl  

    - m -

    diff --git a/globals_func_t.html b/globals_func_t.html index d5dc6f5a..5f2bec23 100644 --- a/globals_func_t.html +++ b/globals_func_t.html @@ -100,7 +100,7 @@ $(document).ready(function(){initNavTree('globals_func_t.html',''); initResizabl  

    - t -