当前位置: 首页>>代码示例>>C++>>正文


C++ SmallVector::Erase方法代码示例

本文整理汇总了C++中SmallVector::Erase方法的典型用法代码示例。如果您正苦于以下问题:C++ SmallVector::Erase方法的具体用法?C++ SmallVector::Erase怎么用?C++ SmallVector::Erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SmallVector的用法示例。


在下文中一共展示了SmallVector::Erase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/**
 * Check whether we need to call the callback, i.e. whether we
 * have connected or aborted and call the appropriate callback
 * for that. It's done this way to ease on the locking that
 * would otherwise be needed everywhere.
 */
/* static */ void TCPConnecter::CheckCallbacks()
{
	for (TCPConnecter **iter = _tcp_connecters.Begin(); iter < _tcp_connecters.End(); /* nothing */) {
		TCPConnecter *cur = *iter;
		if ((cur->connected || cur->aborted) && cur->killed) {
			_tcp_connecters.Erase(iter);
			if (cur->sock != INVALID_SOCKET) closesocket(cur->sock);
			delete cur;
			continue;
		}
		if (cur->connected) {
			_tcp_connecters.Erase(iter);
			cur->OnConnect(cur->sock);
			delete cur;
			continue;
		}
		if (cur->aborted) {
			_tcp_connecters.Erase(iter);
			cur->OnFailure();
			delete cur;
			continue;
		}
		iter++;
	}
}
开发者ID:Johnnei,项目名称:OpenTTD,代码行数:31,代码来源:tcp_connect.cpp

示例2: select

/* static */ void NetworkHTTPSocketHandler::HTTPReceive()
{
	/* No connections, just bail out. */
	if (_http_connections.Length() == 0) return;

	fd_set read_fd;
	struct timeval tv;

	FD_ZERO(&read_fd);
	for (NetworkHTTPSocketHandler **iter = _http_connections.Begin(); iter < _http_connections.End(); iter++) {
		FD_SET((*iter)->sock, &read_fd);
	}

	tv.tv_sec = tv.tv_usec = 0; // don't block at all.
#if !defined(__MORPHOS__) && !defined(__AMIGA__)
	int n = select(FD_SETSIZE, &read_fd, NULL, NULL, &tv);
#else
	int n = WaitSelect(FD_SETSIZE, &read_fd, NULL, NULL, &tv, NULL);
#endif
	if (n == -1) return;

	for (NetworkHTTPSocketHandler **iter = _http_connections.Begin(); iter < _http_connections.End(); /* nothing */) {
		NetworkHTTPSocketHandler *cur = *iter;

		if (FD_ISSET(cur->sock, &read_fd)) {
			int ret = cur->Receive();
			/* First send the failure. */
			if (ret < 0) cur->callback->OnFailure();
			if (ret <= 0) {
				/* Then... the connection can be closed */
				cur->CloseConnection();
				_http_connections.Erase(iter);
				delete cur;
				continue;
			}
		}
		iter++;
	}
}
开发者ID:jemmyw,项目名称:openttd,代码行数:39,代码来源:tcp_http.cpp


注:本文中的SmallVector::Erase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。