/
bin_sort.h
59 lines (46 loc) · 1.18 KB
/
bin_sort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef __BIN_SORT_H__
#define __BIN_SORT_H__
#include <string>
using namespace std;
/*************文件说明****************
* 文件名:bin_sort.h
* 文件功能:实现箱子排序
* 主要步骤:
1、逐个删除输入链表的节点,把删除的节点分配到相应的箱子里;
2、把每一个箱子中的链表收集并链接起来,使其成为一个有序链表。
**/
// 结构体定义
struct studentRecord
{
int score;
std::string* name;
/*
int operator != (const studentRecord& x)const // 重载运算符 !=,它把studentRecord类型转换为数值类型,以实现比较操作和其他目的
{
return (score != x.score);
}*/
operator int() const // 重载类型转换操作符int(),其他算术和关系操作符虽然没有重载或明确定义,但是可以通过int()类型转换操作符转换成int类型完成操作
{
return score;
}
studentRecord() {};
studentRecord(string*name, int score)
{
this->name = name;
this->score = score;
}
};
/*************函数说明****************
* 函数名:
* 函数参数:
* 函数返回值:
* 函数功能:重载运算符<<
ostream& operator<<(ostream& out, const studentRecord& x) // 重载运算符 <<
{
out << x.score << ' ' << *x.name << endl;
return out;
}*/
// 其他函数声明
//void binSort2(chain<studentRecord>& theChain, int range);
#endif // !__BIN_SORT_H__
#pragma once