Skip to content

Code style improvements #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/2darray.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* Simulated by 1-dimension array.
******************************************************************************/

#ifndef __2D_ARRAY_H__
#define __2D_ARRAY_H__
#ifndef ALGO_2D_ARRAY_H__
#define ALGO_2D_ARRAY_H__
#include <stdint.h>
#include <stdlib.h>

Expand Down
6 changes: 3 additions & 3 deletions include/8queen.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* http://en.wikipedia.org/wiki/Eight_queens_puzzle
******************************************************************************/

#ifndef __8QUEEN_H__
#define __8QUEEN_H__
#ifndef ALGO_8QUEEN_H__
#define ALGO_8QUEEN_H__

#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -84,4 +84,4 @@ namespace alg {
};
}

#endif //__8QUEEN_H__
#endif //ALGO_8QUEEN_H__
4 changes: 2 additions & 2 deletions include/astar.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*
******************************************************************************/

#ifndef __ASTAR_H__
#define __ASTAR_H__
#ifndef ALGO_ASTAR_H__
#define ALGO_ASTAR_H__

#include <stdlib.h>
#include <stdint.h>
Expand Down
4 changes: 2 additions & 2 deletions include/avl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*
******************************************************************************/

#ifndef __AVL_H__
#define __AVL_H__
#ifndef ALGO_AVL_H__
#define ALGO_AVL_H__

#include <iostream>
#include <cmath>
Expand Down
4 changes: 2 additions & 2 deletions include/bellman_ford.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
*
******************************************************************************/

#ifndef __BELLMAN_FORD_H__
#define __BELLMAN_FORD_H__
#ifndef ALGO_BELLMAN_FORD_H__
#define ALGO_BELLMAN_FORD_H__

#include <stdio.h>
#include <stdlib.h>
Expand Down
12 changes: 6 additions & 6 deletions include/binary_search_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*
******************************************************************************/

#ifndef __BINARY_SEARCH_TREE_H__
#define __BINARY_SEARCH_TREE_H__
#ifndef ALGO_BINARY_SEARCH_TREE_H__
#define ALGO_BINARY_SEARCH_TREE_H__

#include <stdlib.h>
#include <stdint.h>
Expand Down Expand Up @@ -57,7 +57,7 @@ namespace alg {
BST():m_root(NULL){};

~BST() {
__destruct(m_root);
destruct_(m_root);
}

/**
Expand Down Expand Up @@ -159,10 +159,10 @@ namespace alg {
}

private:
void __destruct(treeNode *n) {
void destruct_(treeNode *n) {
if (n==NULL) return;
__destruct(n->left);
__destruct(n->right);
destruct_(n->left);
destruct_(n->right);
delete n;
}

Expand Down
4 changes: 2 additions & 2 deletions include/bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
*
******************************************************************************/

#ifndef __BIT_SET_H__
#define __BIT_SET_H__
#ifndef ALGO_BIT_SET_H__
#define ALGO_BIT_SET_H__

#include <stdlib.h>
#include <stdint.h>
Expand Down
4 changes: 2 additions & 2 deletions include/bloom_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*
******************************************************************************/

#ifndef __BLOOM_FILTER_H__
#define __BLOOM_FILTER_H__
#ifndef ALGO_BLOOM_FILTER_H__
#define ALGO_BLOOM_FILTER_H__

#include <stdint.h>
#include <stdbool.h>
Expand Down
4 changes: 2 additions & 2 deletions include/btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* http://en.wikipedia.org/wiki/B-tree
******************************************************************************/

#ifndef __BTREE_H__
#define __BTREE_H__
#ifndef ALGO_BTREE_H__
#define ALGO_BTREE_H__

#include <stdio.h>
#include <assert.h>
Expand Down
4 changes: 2 additions & 2 deletions include/dijkstra.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*
******************************************************************************/

#ifndef __DIJKSTRA_H__
#define __DIJKSTRA_H__
#ifndef ALGO_DIJKSTRA_H__
#define ALGO_DIJKSTRA_H__

#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 2 additions & 2 deletions include/directed_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*
******************************************************************************/

#ifndef __DIRECTED_GRAPH_H__
#define __DIRECTED_GRAPH_H__
#ifndef ALGO_DIRECTED_GRAPH_H__
#define ALGO_DIRECTED_GRAPH_H__

#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 2 additions & 2 deletions include/disjoint-set.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
* http://en.wikipedia.org/wiki/Disjoint-set_data_structure
******************************************************************************/

#ifndef __DISJOINTSET_H__
#define __DISJOINTSET_H__
#ifndef ALGO_DISJOINTSET_H__
#define ALGO_DISJOINTSET_H__

namespace alg {
template<typename T>
Expand Down
4 changes: 2 additions & 2 deletions include/dos_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
******************************************************************************/

#ifndef __DOS_TREE_H__
#define __DOS_TREE_H__
#ifndef ALGO_DOS_TREE_H__
#define ALGO_DOS_TREE_H__

#include <stdlib.h>
#include <assert.h>
Expand Down
26 changes: 13 additions & 13 deletions include/double_linked_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* http://en.wikipedia.org/wiki/Double_linked_list
******************************************************************************/

#ifndef __DOUBLE_LINKED_LIST_H__
#define __DOUBLE_LINKED_LIST_H__
#ifndef ALGO_DOUBLE_LINKED_LIST_H__
#define ALGO_DOUBLE_LINKED_LIST_H__

struct list_head {
struct list_head *next, *prev;
Expand All @@ -39,7 +39,7 @@ struct list_head {
* the prev/next entries already!
*/
static inline void
__list_add(struct list_head *n,
list_add_(struct list_head *n,
struct list_head *prev,
struct list_head *next)
{
Expand All @@ -57,14 +57,14 @@ __list_add(struct list_head *n,
* the prev/next entries already!
*/
static inline void
__list_del(struct list_head *prev, struct list_head *next)
list_del_(struct list_head *prev, struct list_head *next)
{
next->prev = prev;
prev->next = next;
}

static inline void
__list_splice(struct list_head *list, struct list_head *head)
list_splice_(struct list_head *list, struct list_head *head)
{
struct list_head *first = list->next;
struct list_head *last = list->prev;
Expand All @@ -88,7 +88,7 @@ __list_splice(struct list_head *list, struct list_head *head)
static inline void
list_add(struct list_head *n, struct list_head *head)
{
__list_add(n, head, head->next);
list_add_(n, head, head->next);
}

/**
Expand All @@ -102,7 +102,7 @@ list_add(struct list_head *n, struct list_head *head)
static inline void
list_add_tail(struct list_head *n, struct list_head *head)
{
__list_add(n, head->prev, head);
list_add_(n, head->prev, head);
}

/**
Expand All @@ -113,7 +113,7 @@ list_add_tail(struct list_head *n, struct list_head *head)
static inline void
list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
list_del_(entry->prev, entry->next);
entry->next = NULL;
entry->prev = NULL;
}
Expand All @@ -125,7 +125,7 @@ list_del(struct list_head *entry)
static inline void
list_del_init(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
list_del_(entry->prev, entry->next);
INIT_LIST_HEAD(entry);
}

Expand All @@ -137,7 +137,7 @@ list_del_init(struct list_head *entry)
static inline void
list_move(struct list_head *list, struct list_head *head)
{
__list_del(list->prev, list->next);
list_del_(list->prev, list->next);
list_add(list, head);
}

Expand All @@ -149,7 +149,7 @@ list_move(struct list_head *list, struct list_head *head)
static inline void
list_move_tail(struct list_head *list, struct list_head *head)
{
__list_del(list->prev, list->next);
list_del_(list->prev, list->next);
list_add_tail(list, head);
}

Expand All @@ -172,7 +172,7 @@ static inline void
list_splice(struct list_head *list, struct list_head *head)
{
if (!list_empty(list))
__list_splice(list, head);
list_splice_(list, head);
}

/**
Expand All @@ -186,7 +186,7 @@ static inline void list_splice_init(struct list_head *list,
struct list_head *head)
{
if (!list_empty(list)) {
__list_splice(list, head);
list_splice_(list, head);
INIT_LIST_HEAD(list);
}
}
Expand Down
4 changes: 2 additions & 2 deletions include/edmonds_karp.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*
******************************************************************************/

#ifndef __EDMONDS_KARP_H__
#define __EDMONDS_KARP_H__
#ifndef ALGO_EDMONDS_KARP_H__
#define ALGO_EDMONDS_KARP_H__

#include <stdlib.h>
#include <stdint.h>
Expand Down
4 changes: 2 additions & 2 deletions include/fenwick_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*
******************************************************************************/

#ifndef __FENWICK_H__
#define __FENWICK_H__
#ifndef ALGO_FENWICK_H__
#define ALGO_FENWICK_H__

#include <vector>

Expand Down
4 changes: 2 additions & 2 deletions include/fib-heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* http://en.wikipedia.org/wiki/Fibonacci_heap
******************************************************************************/

#ifndef __FIB_HEAP_H__
#define __FIB_HEAP_H__
#ifndef ALGO_FIB_HEAP_H__
#define ALGO_FIB_HEAP_H__
#include <math.h>
#include <stdint.h>
#include <unistd.h>
Expand Down
4 changes: 2 additions & 2 deletions include/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*
******************************************************************************/

#ifndef __ALG_INC_H__
#define __ALG_INC_H__
#ifndef ALGO_ALG_INC_H__
#define ALGO_ALG_INC_H__
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
Expand Down
4 changes: 2 additions & 2 deletions include/graph_defs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __GRAPH_DEFS_H__
#define __GRAPH_DEFS_H__
#ifndef ALGO_GRAPH_DEFS_H__
#define ALGO_GRAPH_DEFS_H__

#include "double_linked_list.h"

Expand Down
4 changes: 2 additions & 2 deletions include/graph_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*
******************************************************************************/

#ifndef __BREADTH_FIRST_SEARCH_H__
#define __BREADTH_FIRST_SEARCH_H__
#ifndef ALGO_BREADTH_FIRST_SEARCH_H__
#define ALGO_BREADTH_FIRST_SEARCH_H__

#include <stdio.h>
#include <stdint.h>
Expand Down
4 changes: 2 additions & 2 deletions include/hash_code.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __HASH_CODE_H__
#define __HASH_CODE_H__
#ifndef ALGO_HASH_CODE_H__
#define ALGO_HASH_CODE_H__
#include <string.h>
#include "hash_string.h"
namespace alg {
Expand Down
4 changes: 2 additions & 2 deletions include/hash_multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*
******************************************************************************/

#ifndef __HASH_MULTIPLICATION_H__
#define __HASH_MULTIPLICATION_H__
#ifndef ALGO_HASH_MULTIPLICATION_H__
#define ALGO_HASH_MULTIPLICATION_H__

#include <math.h>
#include <string.h>
Expand Down
4 changes: 2 additions & 2 deletions include/hash_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
*
******************************************************************************/

#ifndef __STRING_HASH_H__
#define __STRING_HASH_H__
#ifndef ALGO_STRING_HASH_H__
#define ALGO_STRING_HASH_H__

#include <stdint.h>

Expand Down
4 changes: 2 additions & 2 deletions include/hash_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*
******************************************************************************/

#ifndef __HASH_TABLE_H__
#define __HASH_TABLE_H__
#ifndef ALGO_HASH_TABLE_H__
#define ALGO_HASH_TABLE_H__

#include <stdint.h>
#include <string.h>
Expand Down
4 changes: 2 additions & 2 deletions include/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
* http://en.wikipedia.org/wiki/Binary_heap
******************************************************************************/

#ifndef __HEAP_H__
#define __HEAP_H__
#ifndef ALGO_HEAP_H__
#define ALGO_HEAP_H__

#include <stdio.h>
#include <stdlib.h>
Expand Down
Loading