Skip to content

Commit bd7da6d

Browse files
authored
Merge pull request #51 from htfy96/master
Code style improvements
2 parents 7882778 + b8b2ed5 commit bd7da6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+170
-170
lines changed

include/2darray.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* Simulated by 1-dimension array.
1111
******************************************************************************/
1212

13-
#ifndef __2D_ARRAY_H__
14-
#define __2D_ARRAY_H__
13+
#ifndef ALGO_2D_ARRAY_H__
14+
#define ALGO_2D_ARRAY_H__
1515
#include <stdint.h>
1616
#include <stdlib.h>
1717

include/8queen.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
* http://en.wikipedia.org/wiki/Eight_queens_puzzle
1010
******************************************************************************/
1111

12-
#ifndef __8QUEEN_H__
13-
#define __8QUEEN_H__
12+
#ifndef ALGO_8QUEEN_H__
13+
#define ALGO_8QUEEN_H__
1414

1515
#include <stdio.h>
1616
#include <string.h>
@@ -84,4 +84,4 @@ namespace alg {
8484
};
8585
}
8686

87-
#endif //__8QUEEN_H__
87+
#endif //ALGO_8QUEEN_H__

include/astar.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*
2020
******************************************************************************/
2121

22-
#ifndef __ASTAR_H__
23-
#define __ASTAR_H__
22+
#ifndef ALGO_ASTAR_H__
23+
#define ALGO_ASTAR_H__
2424

2525
#include <stdlib.h>
2626
#include <stdint.h>

include/avl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*
2020
******************************************************************************/
2121

22-
#ifndef __AVL_H__
23-
#define __AVL_H__
22+
#ifndef ALGO_AVL_H__
23+
#define ALGO_AVL_H__
2424

2525
#include <iostream>
2626
#include <cmath>

include/bellman_ford.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
*
4545
******************************************************************************/
4646

47-
#ifndef __BELLMAN_FORD_H__
48-
#define __BELLMAN_FORD_H__
47+
#ifndef ALGO_BELLMAN_FORD_H__
48+
#define ALGO_BELLMAN_FORD_H__
4949

5050
#include <stdio.h>
5151
#include <stdlib.h>

include/binary_search_tree.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*
1919
******************************************************************************/
2020

21-
#ifndef __BINARY_SEARCH_TREE_H__
22-
#define __BINARY_SEARCH_TREE_H__
21+
#ifndef ALGO_BINARY_SEARCH_TREE_H__
22+
#define ALGO_BINARY_SEARCH_TREE_H__
2323

2424
#include <stdlib.h>
2525
#include <stdint.h>
@@ -57,7 +57,7 @@ namespace alg {
5757
BST():m_root(NULL){};
5858

5959
~BST() {
60-
__destruct(m_root);
60+
destruct_(m_root);
6161
}
6262

6363
/**
@@ -159,10 +159,10 @@ namespace alg {
159159
}
160160

161161
private:
162-
void __destruct(treeNode *n) {
162+
void destruct_(treeNode *n) {
163163
if (n==NULL) return;
164-
__destruct(n->left);
165-
__destruct(n->right);
164+
destruct_(n->left);
165+
destruct_(n->right);
166166
delete n;
167167
}
168168

include/bitset.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
*
1212
******************************************************************************/
1313

14-
#ifndef __BIT_SET_H__
15-
#define __BIT_SET_H__
14+
#ifndef ALGO_BIT_SET_H__
15+
#define ALGO_BIT_SET_H__
1616

1717
#include <stdlib.h>
1818
#include <stdint.h>

include/bloom_filter.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*
1919
******************************************************************************/
2020

21-
#ifndef __BLOOM_FILTER_H__
22-
#define __BLOOM_FILTER_H__
21+
#ifndef ALGO_BLOOM_FILTER_H__
22+
#define ALGO_BLOOM_FILTER_H__
2323

2424
#include <stdint.h>
2525
#include <stdbool.h>

include/btree.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
* http://en.wikipedia.org/wiki/B-tree
2525
******************************************************************************/
2626

27-
#ifndef __BTREE_H__
28-
#define __BTREE_H__
27+
#ifndef ALGO_BTREE_H__
28+
#define ALGO_BTREE_H__
2929

3030
#include <stdio.h>
3131
#include <assert.h>

include/dijkstra.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*
2020
******************************************************************************/
2121

22-
#ifndef __DIJKSTRA_H__
23-
#define __DIJKSTRA_H__
22+
#ifndef ALGO_DIJKSTRA_H__
23+
#define ALGO_DIJKSTRA_H__
2424

2525
#include <stdio.h>
2626
#include <stdlib.h>

include/directed_graph.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*
1515
******************************************************************************/
1616

17-
#ifndef __DIRECTED_GRAPH_H__
18-
#define __DIRECTED_GRAPH_H__
17+
#ifndef ALGO_DIRECTED_GRAPH_H__
18+
#define ALGO_DIRECTED_GRAPH_H__
1919

2020
#include <stdio.h>
2121
#include <stdlib.h>

include/disjoint-set.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
* http://en.wikipedia.org/wiki/Disjoint-set_data_structure
1919
******************************************************************************/
2020

21-
#ifndef __DISJOINTSET_H__
22-
#define __DISJOINTSET_H__
21+
#ifndef ALGO_DISJOINTSET_H__
22+
#define ALGO_DISJOINTSET_H__
2323

2424
namespace alg {
2525
template<typename T>

include/dos_tree.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*
1717
******************************************************************************/
1818

19-
#ifndef __DOS_TREE_H__
20-
#define __DOS_TREE_H__
19+
#ifndef ALGO_DOS_TREE_H__
20+
#define ALGO_DOS_TREE_H__
2121

2222
#include <stdlib.h>
2323
#include <assert.h>

include/double_linked_list.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* http://en.wikipedia.org/wiki/Double_linked_list
1717
******************************************************************************/
1818

19-
#ifndef __DOUBLE_LINKED_LIST_H__
20-
#define __DOUBLE_LINKED_LIST_H__
19+
#ifndef ALGO_DOUBLE_LINKED_LIST_H__
20+
#define ALGO_DOUBLE_LINKED_LIST_H__
2121

2222
struct list_head {
2323
struct list_head *next, *prev;
@@ -39,7 +39,7 @@ struct list_head {
3939
* the prev/next entries already!
4040
*/
4141
static inline void
42-
__list_add(struct list_head *n,
42+
list_add_(struct list_head *n,
4343
struct list_head *prev,
4444
struct list_head *next)
4545
{
@@ -57,14 +57,14 @@ __list_add(struct list_head *n,
5757
* the prev/next entries already!
5858
*/
5959
static inline void
60-
__list_del(struct list_head *prev, struct list_head *next)
60+
list_del_(struct list_head *prev, struct list_head *next)
6161
{
6262
next->prev = prev;
6363
prev->next = next;
6464
}
6565

6666
static inline void
67-
__list_splice(struct list_head *list, struct list_head *head)
67+
list_splice_(struct list_head *list, struct list_head *head)
6868
{
6969
struct list_head *first = list->next;
7070
struct list_head *last = list->prev;
@@ -88,7 +88,7 @@ __list_splice(struct list_head *list, struct list_head *head)
8888
static inline void
8989
list_add(struct list_head *n, struct list_head *head)
9090
{
91-
__list_add(n, head, head->next);
91+
list_add_(n, head, head->next);
9292
}
9393

9494
/**
@@ -102,7 +102,7 @@ list_add(struct list_head *n, struct list_head *head)
102102
static inline void
103103
list_add_tail(struct list_head *n, struct list_head *head)
104104
{
105-
__list_add(n, head->prev, head);
105+
list_add_(n, head->prev, head);
106106
}
107107

108108
/**
@@ -113,7 +113,7 @@ list_add_tail(struct list_head *n, struct list_head *head)
113113
static inline void
114114
list_del(struct list_head *entry)
115115
{
116-
__list_del(entry->prev, entry->next);
116+
list_del_(entry->prev, entry->next);
117117
entry->next = NULL;
118118
entry->prev = NULL;
119119
}
@@ -125,7 +125,7 @@ list_del(struct list_head *entry)
125125
static inline void
126126
list_del_init(struct list_head *entry)
127127
{
128-
__list_del(entry->prev, entry->next);
128+
list_del_(entry->prev, entry->next);
129129
INIT_LIST_HEAD(entry);
130130
}
131131

@@ -137,7 +137,7 @@ list_del_init(struct list_head *entry)
137137
static inline void
138138
list_move(struct list_head *list, struct list_head *head)
139139
{
140-
__list_del(list->prev, list->next);
140+
list_del_(list->prev, list->next);
141141
list_add(list, head);
142142
}
143143

@@ -149,7 +149,7 @@ list_move(struct list_head *list, struct list_head *head)
149149
static inline void
150150
list_move_tail(struct list_head *list, struct list_head *head)
151151
{
152-
__list_del(list->prev, list->next);
152+
list_del_(list->prev, list->next);
153153
list_add_tail(list, head);
154154
}
155155

@@ -172,7 +172,7 @@ static inline void
172172
list_splice(struct list_head *list, struct list_head *head)
173173
{
174174
if (!list_empty(list))
175-
__list_splice(list, head);
175+
list_splice_(list, head);
176176
}
177177

178178
/**
@@ -186,7 +186,7 @@ static inline void list_splice_init(struct list_head *list,
186186
struct list_head *head)
187187
{
188188
if (!list_empty(list)) {
189-
__list_splice(list, head);
189+
list_splice_(list, head);
190190
INIT_LIST_HEAD(list);
191191
}
192192
}

include/edmonds_karp.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
*
2222
******************************************************************************/
2323

24-
#ifndef __EDMONDS_KARP_H__
25-
#define __EDMONDS_KARP_H__
24+
#ifndef ALGO_EDMONDS_KARP_H__
25+
#define ALGO_EDMONDS_KARP_H__
2626

2727
#include <stdlib.h>
2828
#include <stdint.h>

include/fenwick_tree.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*
1515
******************************************************************************/
1616

17-
#ifndef __FENWICK_H__
18-
#define __FENWICK_H__
17+
#ifndef ALGO_FENWICK_H__
18+
#define ALGO_FENWICK_H__
1919

2020
#include <vector>
2121

include/fib-heap.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* http://en.wikipedia.org/wiki/Fibonacci_heap
1818
******************************************************************************/
1919

20-
#ifndef __FIB_HEAP_H__
21-
#define __FIB_HEAP_H__
20+
#ifndef ALGO_FIB_HEAP_H__
21+
#define ALGO_FIB_HEAP_H__
2222
#include <math.h>
2323
#include <stdint.h>
2424
#include <unistd.h>

include/generic.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
*
1010
******************************************************************************/
1111

12-
#ifndef __ALG_INC_H__
13-
#define __ALG_INC_H__
12+
#ifndef ALGO_ALG_INC_H__
13+
#define ALGO_ALG_INC_H__
1414
#include <stdio.h>
1515
#include <stdint.h>
1616
#include <assert.h>

include/graph_defs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef __GRAPH_DEFS_H__
2-
#define __GRAPH_DEFS_H__
1+
#ifndef ALGO_GRAPH_DEFS_H__
2+
#define ALGO_GRAPH_DEFS_H__
33

44
#include "double_linked_list.h"
55

include/graph_search.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*
2121
******************************************************************************/
2222

23-
#ifndef __BREADTH_FIRST_SEARCH_H__
24-
#define __BREADTH_FIRST_SEARCH_H__
23+
#ifndef ALGO_BREADTH_FIRST_SEARCH_H__
24+
#define ALGO_BREADTH_FIRST_SEARCH_H__
2525

2626
#include <stdio.h>
2727
#include <stdint.h>

include/hash_code.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef __HASH_CODE_H__
2-
#define __HASH_CODE_H__
1+
#ifndef ALGO_HASH_CODE_H__
2+
#define ALGO_HASH_CODE_H__
33
#include <string.h>
44
#include "hash_string.h"
55
namespace alg {

include/hash_multi.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*
1616
******************************************************************************/
1717

18-
#ifndef __HASH_MULTIPLICATION_H__
19-
#define __HASH_MULTIPLICATION_H__
18+
#ifndef ALGO_HASH_MULTIPLICATION_H__
19+
#define ALGO_HASH_MULTIPLICATION_H__
2020

2121
#include <math.h>
2222
#include <string.h>

include/hash_string.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
*
1313
******************************************************************************/
1414

15-
#ifndef __STRING_HASH_H__
16-
#define __STRING_HASH_H__
15+
#ifndef ALGO_STRING_HASH_H__
16+
#define ALGO_STRING_HASH_H__
1717

1818
#include <stdint.h>
1919

include/hash_table.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*
1515
******************************************************************************/
1616

17-
#ifndef __HASH_TABLE_H__
18-
#define __HASH_TABLE_H__
17+
#ifndef ALGO_HASH_TABLE_H__
18+
#define ALGO_HASH_TABLE_H__
1919

2020
#include <stdint.h>
2121
#include <string.h>

include/heap.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
* http://en.wikipedia.org/wiki/Binary_heap
2929
******************************************************************************/
3030

31-
#ifndef __HEAP_H__
32-
#define __HEAP_H__
31+
#ifndef ALGO_HEAP_H__
32+
#define ALGO_HEAP_H__
3333

3434
#include <stdio.h>
3535
#include <stdlib.h>

0 commit comments

Comments
 (0)