本文整理汇总了C++中SmallSet::Overflowed方法的典型用法代码示例。如果您正苦于以下问题:C++ SmallSet::Overflowed方法的具体用法?C++ SmallSet::Overflowed怎么用?C++ SmallSet::Overflowed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmallSet
的用法示例。
在下文中一共展示了SmallSet::Overflowed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateSignalsInBuffer
/**
* Updates blocks in _globset buffer
*
* @param owner company whose signals we are updating
* @return state of the first block from _globset
* @pre Company::IsValidID(owner)
*/
static SigSegState UpdateSignalsInBuffer(Owner owner)
{
assert(Company::IsValidID(owner));
bool first = true; // first block?
SigSegState state = SIGSEG_FREE; // value to return
TileIndex tile;
DiagDirection dir;
while (_globset.Get(&tile, &dir)) {
assert(_tbuset.IsEmpty());
assert(_tbdset.IsEmpty());
/* After updating signal, data stored are always MP_RAILWAY with signals.
* Other situations happen when data are from outside functions -
* modification of railbits (including both rail building and removal),
* train entering/leaving block, train leaving depot...
*/
switch (GetTileType(tile)) {
case MP_TUNNELBRIDGE:
/* 'optimization assert' - do not try to update signals when it is not needed */
assert(GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL);
assert(dir == INVALID_DIAGDIR || dir == ReverseDiagDir(GetTunnelBridgeDirection(tile)));
_tbdset.Add(tile, INVALID_DIAGDIR); // we can safely start from wormhole centre
_tbdset.Add(GetOtherTunnelBridgeEnd(tile), INVALID_DIAGDIR);
break;
case MP_RAILWAY:
if (IsRailDepot(tile)) {
/* 'optimization assert' do not try to update signals in other cases */
assert(dir == INVALID_DIAGDIR || dir == GetRailDepotDirection(tile));
_tbdset.Add(tile, INVALID_DIAGDIR); // start from depot inside
break;
}
/* FALL THROUGH */
case MP_STATION:
case MP_ROAD:
if ((TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0)) & _enterdir_to_trackbits[dir]) != TRACK_BIT_NONE) {
/* only add to set when there is some 'interesting' track */
_tbdset.Add(tile, dir);
_tbdset.Add(tile + TileOffsByDiagDir(dir), ReverseDiagDir(dir));
break;
}
/* FALL THROUGH */
default:
/* jump to next tile */
tile = tile + TileOffsByDiagDir(dir);
dir = ReverseDiagDir(dir);
if ((TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0)) & _enterdir_to_trackbits[dir]) != TRACK_BIT_NONE) {
_tbdset.Add(tile, dir);
break;
}
/* happens when removing a rail that wasn't connected at one or both sides */
continue; // continue the while() loop
}
assert(!_tbdset.Overflowed()); // it really shouldn't overflow by these one or two items
assert(!_tbdset.IsEmpty()); // it wouldn't hurt anyone, but shouldn't happen too
SigFlags flags = ExploreSegment(owner);
if (first) {
first = false;
/* SIGSEG_FREE is set by default */
if (flags & SF_PBS) {
state = SIGSEG_PBS;
} else if ((flags & SF_TRAIN) || ((flags & SF_EXIT) && !(flags & SF_GREEN)) || (flags & SF_FULL)) {
state = SIGSEG_FULL;
}
}
/* do not do anything when some buffer was full */
if (flags & SF_FULL) {
ResetSets(); // free all sets
break;
}
UpdateSignalsAroundSegment(flags);
}
return state;
}