Skip to content

Commit

Permalink
fix compatiblity with clang
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Nov 20, 2013
1 parent 5edc0c6 commit 91493ec
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 25 deletions.
2 changes: 1 addition & 1 deletion include/astar.h
Expand Up @@ -49,7 +49,6 @@ namespace alg {
};

static const unsigned char WALL = 0xFF;
static const float SQRT2 = 1.414213562373095;

private:
const Array2D<unsigned char> & m_grid;
Expand All @@ -72,6 +71,7 @@ namespace alg {
* a integer representing path is returned, you should delete it after.
*/
AStarResult * run(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2) {
static float SQRT2 = 1.414213562373095;
uint32_t nrow = m_grid.row();
uint32_t ncol = m_grid.col();
m_closedset.clear(false);
Expand Down
3 changes: 1 addition & 2 deletions include/binary_search_tree.h
Expand Up @@ -46,11 +46,10 @@ namespace alg {
virtual const char * what() const throw() {
return "key does not exist";
}
};
} excp_key;

private:
treeNode * m_root; // the root
const BSTException error;
private:
BST(const BST&);
BST& operator=(const BST&);
Expand Down
2 changes: 1 addition & 1 deletion include/dijkstra.h
Expand Up @@ -38,7 +38,7 @@ namespace alg {
public:
static const int UNDEFINED = -1;
// run dijkstra algorithm, and return the previous table
static HashTable<int32_t, int32_t> * run(const struct Graph & g, uint32_t src_id) {
static HashTable<int32_t, int32_t> * run(const Graph & g, uint32_t src_id) {
// a binary heap
Heap<uint32_t> Q(g.vertex_count() + g.edge_count());
// distance hash table
Expand Down
2 changes: 1 addition & 1 deletion include/fib-heap.h
Expand Up @@ -83,7 +83,7 @@ namespace alg {
H->m_root = H1->m_root;
list_splice(&H->m_root, &H1->m_root); // concat 2 root-list
list_splice(&H->m_root, &H2->m_root);
if (H1->min == NULL || (H2.min != NULL && H2->min.key < H1->min.key)) {
if (H1->min == NULL || (H2->min != NULL && H2->min.key < H1->min.key)) {
H->min = H2->min;
}
H->n = H1->n + H2->n;
Expand Down
2 changes: 1 addition & 1 deletion include/lcs.h
Expand Up @@ -64,7 +64,7 @@ namespace alg {
* pass an empty stack, pop out the result in sequential order.
*/
template<typename T>
static void lcs_backtrack(Stack<int> & S, struct Array2D<uint32_t> & A,
static void lcs_backtrack(Stack<int> & S, Array2D<uint32_t> & A,
const T X[], const T Y[],
const uint32_t i, uint32_t j) {
if (i==0 || j==0) return;
Expand Down
8 changes: 3 additions & 5 deletions include/perfect_hash.h
Expand Up @@ -29,10 +29,10 @@ namespace alg {
virtual const char * what() const throw() {
return "key does not exist";
}
};
} excp_key;

// Level-2 Slot definition
class SlotL2 {
struct SlotL2 {
public:
uint32_t cnt; // collison count
uint32_t key; //key
Expand All @@ -57,8 +57,6 @@ namespace alg {
struct SlotL1 * slots; // level 1 slots
struct UHash params; // 1st level
uint32_t num_slots;
const PerfHTException error;

public:
PerfHT(uint32_t keys[], uint32_t len) {
// remove duplicate keys
Expand Down Expand Up @@ -105,7 +103,7 @@ namespace alg {
}
}

throw error;
throw excp_key;
}

/**
Expand Down
6 changes: 2 additions & 4 deletions include/queue.h
Expand Up @@ -32,7 +32,7 @@ namespace alg {
virtual const char * what() const throw() {
return "Queue is empty.";
}
};
} excp_empty;

private:
uint32_t m_capacity; // queue capacity
Expand All @@ -41,8 +41,6 @@ namespace alg {
uint32_t m_rear; // index of the last element
T * m_elements; // the elements

const QueueEmptyException exp_empty;

public:
/**
* constructor takes argument the maximum number of elements the Queue
Expand Down Expand Up @@ -88,7 +86,7 @@ namespace alg {
* return the front element.
*/
inline const T& front() const {
if (m_size==0) throw exp_empty;
if (m_size==0) throw excp_empty;
return m_elements[m_front];
};

Expand Down
3 changes: 1 addition & 2 deletions include/skiplist.h
Expand Up @@ -40,8 +40,7 @@ namespace alg {
virtual const char * what() const throw() {
return "cannot find the element in skiplist";
}
};
const NotFoundException excp_notfound;
} excp_notfound;

public:
SkipList() {
Expand Down
10 changes: 4 additions & 6 deletions include/stack.h
Expand Up @@ -36,21 +36,19 @@ namespace alg {
{
return "stack is empty";
}
};
} excp_empty;

class StackIndexOutOfBoundException: public std::exception {
public:
virtual const char * what() const throw()
{
return "Index out of bound.";
}
};
} excp_ioob;

uint32_t m_capacity; // the total capacity
uint32_t m_size; // current stack size
T * m_elements; // the elements
const StackEmptyException exp_empty;
const StackIndexOutOfBoundException exp_ioob;

public:
/**
Expand Down Expand Up @@ -90,7 +88,7 @@ namespace alg {
* get the top element
*/
inline const T& top() const {
if (m_size==0) throw exp_empty;
if (m_size==0) throw excp_empty;
return m_elements[m_size-1];
}

Expand All @@ -115,7 +113,7 @@ namespace alg {
* return value by index
*/
inline const T& operator[] (uint32_t idx) const {
if (idx<0 || idx >= m_capacity) throw exp_ioob;
if (idx >= m_capacity) throw excp_ioob;
return m_elements[m_size-1-idx];
}
};
Expand Down
2 changes: 0 additions & 2 deletions include/word_seg.h
Expand Up @@ -123,8 +123,6 @@ namespace alg {
*/
private:
HashTable<uint32_t, WordEP> wordht; // a WORD-> WordEP hashtable
uint32_t words[GB18030_NR]; // every char in GB18030

public:
WordSeg() : wordht(GB18030_NR){ }

Expand Down

0 comments on commit 91493ec

Please sign in to comment.