Skip to content

Commit

Permalink
add explicit specifier
Browse files Browse the repository at this point in the history
  • Loading branch information
landerrosette committed Nov 27, 2024
1 parent 0dcfdeb commit 62b9e41
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion BinarySearchST.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BinarySearchST : public OrderedST<Key, Value> {
int N = 0;

public:
BinarySearchST(int capacity) : keys_(capacity), vals(capacity) {}
explicit BinarySearchST(int capacity) : keys_(capacity), vals(capacity) {}

std::optional<Value> get(const Key &key) const override;

Expand Down
2 changes: 1 addition & 1 deletion BoyerMoore.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BoyerMoore : public SubstrSearcher {
std::string pat;

public:
BoyerMoore(const std::string &pat);
explicit BoyerMoore(const std::string &pat);

int search(const std::string &txt) const override;
};
Expand Down
2 changes: 1 addition & 1 deletion CC.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class CC : public CCBase {
public:
CC(const Graph &G);
explicit CC(const Graph &G);
};


Expand Down
2 changes: 1 addition & 1 deletion CCBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CCBase {
void dfs(const GraphBase<int> &G, int v);

public:
CCBase(const GraphBase<int> &G) : marked(G.V()), id_(G.V()) {}
explicit CCBase(const GraphBase<int> &G) : marked(G.V()), id_(G.V()) {}

virtual ~CCBase() = default;

Expand Down
2 changes: 1 addition & 1 deletion DepthFirstOrder.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DepthFirstOrder {

public:
template<typename T>
DepthFirstOrder(const GraphBase<T> &G);
explicit DepthFirstOrder(const GraphBase<T> &G);

std::list<int> pre() const { return pre_; }

Expand Down
4 changes: 2 additions & 2 deletions Digraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class Digraph : public GraphBase<int> {
public:
Digraph(int V) : GraphBase(V) {}
explicit Digraph(int V) : GraphBase(V) {}

Digraph(std::istream &in);
explicit Digraph(std::istream &in);

void addEdge(int v, int w);

Expand Down
2 changes: 1 addition & 1 deletion DirectedCycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DirectedCycle {
void dfs(const GraphBase<T> &G, int v);

public:
DirectedCycle(const GraphBase<T> &G);
explicit DirectedCycle(const GraphBase<T> &G);

bool hasCycle() const { return !cycle_.empty(); }

Expand Down
4 changes: 2 additions & 2 deletions EdgeWeightedDigraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

class EdgeWeightedDigraph : public GraphBase<DirectedEdge> {
public:
EdgeWeightedDigraph(int V) : GraphBase(V) {}
explicit EdgeWeightedDigraph(int V) : GraphBase(V) {}

EdgeWeightedDigraph(std::istream &in);
explicit EdgeWeightedDigraph(std::istream &in);

void addEdge(const DirectedEdge &e);

Expand Down
4 changes: 2 additions & 2 deletions EdgeWeightedGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

class EdgeWeightedGraph : public GraphBase<Edge> {
public:
EdgeWeightedGraph(int V) : GraphBase(V) {}
explicit EdgeWeightedGraph(int V) : GraphBase(V) {}

EdgeWeightedGraph(std::istream &in);
explicit EdgeWeightedGraph(std::istream &in);

void addEdge(const Edge &e);

Expand Down
4 changes: 2 additions & 2 deletions Graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class Graph : public GraphBase<int> {
public:
Graph(int V) : GraphBase(V) {}
explicit Graph(int V) : GraphBase(V) {}

Graph(std::istream &in);
explicit Graph(std::istream &in);

void addEdge(int v, int w);
};
Expand Down
4 changes: 2 additions & 2 deletions GraphBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class GraphBase {
std::vector<std::list<T> > adj_; // 邻接表

public:
GraphBase(int V) : V_(V), E_(0), adj_(V) {}
explicit GraphBase(int V) : V_(V), E_(0), adj_(V) {}

GraphBase(std::istream &in);
explicit GraphBase(std::istream &in);

virtual ~GraphBase() = default;

Expand Down
2 changes: 1 addition & 1 deletion IndexMinPQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IndexMinPQ : private MinPQ<int> {
void exch(int i, int j) override;

public:
IndexMinPQ(int maxN) : MinPQ(maxN), qp(maxN + 1), keys(maxN + 1) {}
explicit IndexMinPQ(int maxN) : MinPQ(maxN), qp(maxN + 1), keys(maxN + 1) {}

using MinPQ::isEmpty, MinPQ::size;

Expand Down
2 changes: 1 addition & 1 deletion KMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class KMP : public SubstrSearcher {
std::vector<std::vector<int> > dfa;

public:
KMP(const std::string &pat);
explicit KMP(const std::string &pat);

int search(const std::string &txt) const override;
};
Expand Down
2 changes: 1 addition & 1 deletion KosarajuSCC.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class KosarajuSCC : public CCBase {
public:
KosarajuSCC(const Digraph &G);
explicit KosarajuSCC(const Digraph &G);

bool stronglyConnected(int v, int w) const { return connected(v, w); }
};
Expand Down
2 changes: 1 addition & 1 deletion KruskalMST.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class KruskalMST : public MST {
std::list<Edge> mst;

public:
KruskalMST(const EdgeWeightedGraph &G);
explicit KruskalMST(const EdgeWeightedGraph &G);

std::list<Edge> edges() const override { return mst; }
};
Expand Down
2 changes: 1 addition & 1 deletion LinearProbingHashST.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LinearProbingHashST : public ST<Key, Value> {

int hash(const Key &key) const;

LinearProbingHashST(int M) : M(M), keys_(M), vals(M) {}
explicit LinearProbingHashST(int M) : M(M), keys_(M), vals(M) {}

void resize(int cap);

Expand Down
2 changes: 1 addition & 1 deletion PQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PQ {
std::optional<Key> delTop();

public:
PQ(int maxN) : pq(maxN + 1) {}
explicit PQ(int maxN) : pq(maxN + 1) {}

virtual ~PQ() = default;

Expand Down
2 changes: 1 addition & 1 deletion PrimMST.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PrimMST : public MST {
void visit(const EdgeWeightedGraph &G, int v);

public:
PrimMST(const EdgeWeightedGraph &G);
explicit PrimMST(const EdgeWeightedGraph &G);

std::list<Edge> edges() const override;
};
Expand Down
2 changes: 1 addition & 1 deletion SeparateChainingHashST.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SeparateChainingHashST : public ST<Key, Value> {
int hash(const Key &key) const;

public:
SeparateChainingHashST(int M) : M(M), st(M) {}
explicit SeparateChainingHashST(int M) : M(M), st(M) {}

std::optional<Value> get(const Key &key) const override { return st[hash(key)].get(key); }

Expand Down
2 changes: 1 addition & 1 deletion TST.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TST : public StringST<Value> {
std::shared_ptr<Node> left, mid, right;
std::optional<Value> val;

Node(char c) : c(c) {}
explicit Node(char c) : c(c) {}
};

std::shared_ptr<Node> root;
Expand Down
2 changes: 1 addition & 1 deletion Topological.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Topological {

public:
template<typename T>
Topological(const GraphBase<T> &G);
explicit Topological(const GraphBase<T> &G);

std::list<int> order() const { return order_; }

Expand Down
2 changes: 1 addition & 1 deletion UF.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class UF {
int count_; // 分量数量

public:
UF(int N);
explicit UF(int N);

int count() const { return count_; }

Expand Down

0 comments on commit 62b9e41

Please sign in to comment.