图  0.1
数据结构_第13章
ch8_3.cc File Reference

程序设计题第3题:用operator+,*,/实现存储在数组中的集合的并, 交, 差 More...

#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iostream>
#include <vector>
Include dependency graph for ch8_3.cc:

Go to the source code of this file.

Functions

template<class T >
std::vector< T > operator+ (const std::vector< T > &vec1, const std::vector< T > &vec2)
 返回两个非降序vector集合的并集vector More...
 
template<class T >
std::vector< T > operator* (const std::vector< T > &vec1, const std::vector< T > &vec2)
 返回两个非降序vector集合的交集vector More...
 
template<class T >
std::vector< T > operator- (const std::vector< T > &vec1, const std::vector< T > &vec2)
 返回两个非降序vector集合的差集vector More...
 
int main (int argc, char const *argv[])
 测试程序 More...
 

Detailed Description

程序设计题第3题:用operator+,*,/实现存储在数组中的集合的并, 交, 差

Author
Guorui Wei (31301.nosp@m.7602.nosp@m.@qq.c.nosp@m.om)
Version
0.1
Date
2020-07-05

See the file LICENSE in the top directory of this distribution for more information.

Definition in file ch8_3.cc.

Function Documentation

◆ main()

int main ( int  argc,
char const *  argv[] 
)

测试程序

Parameters
argc参数个数
argv参数数组
Returns
int 返回值
Warning
要求.exe对其所在的目录有读写权限

部分测试结果将输出到一个文本文档中

Definition at line 63 of file ch8_3.cc.

◆ operator*()

template<class T >
std::vector< T > operator* ( const std::vector< T > &  vec1,
const std::vector< T > &  vec2 
)

返回两个非降序vector集合的交集vector

Template Parameters
T元素的类型
Parameters
vec1集合1
vec2集合2
Returns
std::vector<T> 集合1和集合2的交

Input iterators to the initial and final positions of the first sorted sequence.

The range used is [first1,last1), which contains all the elements between first1 and last1, including the element pointed by first1 but not the element pointed by last1.

Input iterators to the initial and final positions of the second sorted sequence.

The range used is [first2,last2).

Output iterator to the initial position of the range where the resulting sequence is stored.

The pointed type shall support being assigned the value of an element from the other ranges.

Definition at line 264 of file ch8_3.cc.

◆ operator+()

template<class T >
std::vector< T > operator+ ( const std::vector< T > &  vec1,
const std::vector< T > &  vec2 
)

返回两个非降序vector集合的并集vector

Template Parameters
T元素的类型
Parameters
vec1集合1
vec2集合2
Returns
std::vector<T> 集合1和集合2的并

Input iterators to the initial and final positions of the first sorted sequence.

The range used is [first1,last1), which contains all the elements between first1 and last1, including the element pointed by first1 but not the element pointed by last1.

Input iterators to the initial and final positions of the second sorted sequence.

The range used is [first2,last2).

Output iterator to the initial position of the range where the resulting sequence is stored.

The pointed type shall support being assigned the value of an element from the other ranges.

Definition at line 203 of file ch8_3.cc.

◆ operator-()

template<class T >
std::vector< T > operator- ( const std::vector< T > &  vec1,
const std::vector< T > &  vec2 
)

返回两个非降序vector集合的差集vector

Template Parameters
T元素的类型
Parameters
vec1集合1
vec2集合2
Returns
std::vector<T> 集合1和集合2的差

Input iterators to the initial and final positions of the first sorted sequence.

The range used is [first1,last1), which contains all the elements between first1 and last1, including the element pointed by first1 but not the element pointed by last1.

Input iterators to the initial and final positions of the second sorted sequence.

The range used is [first2,last2).

Output iterator to the initial position of the range where the resulting sequence is stored.

The pointed type shall support being assigned the value of an element from the other ranges.

Definition at line 308 of file ch8_3.cc.