Skip to content

Commit

Permalink
移去virtual函数
Browse files Browse the repository at this point in the history
  • Loading branch information
senlinzhan committed Aug 10, 2015
1 parent 8638453 commit 51db252
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion avl_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class avl_tree
}

// call root_'s destructor, all nodes' memory will be free
virtual ~avl_tree() = default;
~avl_tree() = default;

void swap( avl_tree &tree ) noexcept
{
Expand Down
3 changes: 1 addition & 2 deletions binary_tree.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/***
二叉搜索树
1. 使用智能指针自动管理内存
2. 使用虚析构函数,允许定义 binary_tree 的派生类
3. 引入异常,对于不合法的操作会抛出异常
4. 支持输入迭代器
Expand Down Expand Up @@ -244,7 +243,7 @@ class binary_tree
}

// call root_'s destructor, all nodes' memory will be free
virtual ~binary_tree() = default;
~binary_tree() = default;

void swap( binary_tree &tree ) noexcept
{
Expand Down
3 changes: 1 addition & 2 deletions forward_list.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/***
单向链表
1. 使用智能指针自动管理内存
2. 使用虚析构函数,允许定义 forward_list 的派生类
3. 引入异常,对于不合法的操作会抛出异常
4. 不允许使用 allocator 来分配内存
Expand Down Expand Up @@ -234,7 +233,7 @@ class forward_list
/**
call head_'s destructor, all nodes' memory will be free
**/
virtual ~forward_list() = default;
~forward_list() = default;

/**
can handle the problem of self-assignment, see C++ Primer 5th section 13.3
Expand Down
2 changes: 1 addition & 1 deletion list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class list
}

// call head_'s destructor, all nodes' memory will be free
virtual ~list() = default;
~list() = default;

void swap( list &other ) noexcept
{
Expand Down
2 changes: 2 additions & 0 deletions priority_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class priority_queue
mystl::make_heap( container_.begin(), container_.end(), comp_ );
}

~priority_queue() = default;

bool empty() const
{
return container_.empty();
Expand Down
2 changes: 1 addition & 1 deletion queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class queue
{
}

virtual ~queue() = default;
~queue() = default;

bool empty() const
{
Expand Down
2 changes: 1 addition & 1 deletion unordered_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class unordered_set
swap( other );
}

virtual ~unordered_set() = default;
~unordered_set() = default;

unordered_set &operator=( const unordered_set &other )
{
Expand Down
2 changes: 1 addition & 1 deletion vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class vector
assign( lst.begin(), lst.end() );
}

virtual ~vector()
~vector()
{
clear_elements();
}
Expand Down

0 comments on commit 51db252

Please sign in to comment.