remove 用法

removefunction template
template < class ForwardIterator, class T >
  ForwardIterator remove ( ForwardIterator first, ForwardIterator last,
                           const T& value );
<algorithm>

Remove value from range

Removes from the range [first,last) the elements with a value equal to value and returns an iterator to the new end of the range, which now includes only the values not equal to value.

The behavior of this function template is equivalent to:

template < class ForwardIterator, class T >
  ForwardIterator remove ( ForwardIterator first, ForwardIterator last, const T& value )
{
  ForwardIterator result = first;
  for ( ; first != last; ++first)
    if (!(*first == value)) *result++ = *first;
  return result;
}

Notice that this function does not alter the elements past the new end, which keep their old values and are still accessible.

Parameters

first, last
Forward iterators to the initial and final positions in a sequence. The range used is  [first,last), which contains all the elements between  first and  last, including the element pointed by  first but not the element pointed by  last.
value
Value to be removed.

Return value

A forward iterator pointing to the new end of the sequence, which now includes all the elements with a value other than  value.
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
class student{
	public:
		int key;
		int value;
	bool operator==(student s){
		return value==s.value;
}
};
int main(){
	vector<student>vec(4);
	vec[0].key=1;
	vec[0].value=1;
	vec[1].key=2;
	vec[1].value=2;
	vec[2].key=2;
	vec[2].value=2;
	vec[3].key=3;
	vec[3].value=3;
	vector<student>::iterator it,p;
	p=remove(vec.begin(),vec.end(),vec[2]);
	for(it=vec.begin();it!=p;it++)
		cout<<(*it).value<<endl;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
软件介绍: USB Safely Remove 5.3.3简体文特别版,直接安装后即是正式版,不需要注册码。USB Safely Remove是一款USB设备安全删除工具。设备电源管理:设备停止后断开电源,注意!当该选项启用后,在极少数的情况下某些设备可能无法正常的工作。请在明白您正在做什么的情况下使用。驱动器检测:显示不需要停止的USB设备,如果你不想看到无法删除的可插拔USBy几回,请禁用此功能,例如鼠标、打印机等。显示所有存储设备:你可以操作所有(包括不允许停止的)存储设备,当无法在停止菜单看到SATA或火线驱动器时,你可以开启本功能。支持自定义皮肤,你可以选择你喜欢的皮肤。支持定义全局热键,全局热键是一组快捷键,可以在任何程序使用,你可以使用该快捷键来显示设备停止菜单。盘符管理: 当没有媒体插入时隐藏盘符 (系统设置),当你使用读卡器时,该功能十分有用,通常读卡器会在系统创建多余的空的驱动器,使用此功能,你将只会看到插槽插入记忆卡的盘符,而不会看到空的盘符。不允许将以下的盘符指定为热插拔设备,这将阻止WINDOWS分配指定的盘符给热插拔设备,例如闪存USB驱动器等。如果你使用网络驱动器,这将很有用,用法:E,G,H。固定盘符列表,将显示所有固定盘符,如果你手边没有设备或设备丢失,你可以在此管理这些盘符,你可以选择取消固定徐徐以便于其他驱动器使用。开启冗余日志,该功能会增加大量的信息到程序的日志文件。建议在需要支持服务时开启。注意!开启该功能后,程序的日志会快速的增长。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值