本文整理汇总了C++中datastructures::List::Push方法的典型用法代码示例。如果您正苦于以下问题:C++ List::Push方法的具体用法?C++ List::Push怎么用?C++ List::Push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datastructures::List
的用法示例。
在下文中一共展示了List::Push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bsIn
void FullyConnectedMesh2::GetVerifiedJoinAcceptedAdditionalData(Packet *packet, bool *thisSystemAccepted, DataStructures::List<RakNetGUID> &systemsAccepted, BitStream *additionalData)
{
systemsAccepted.Clear(true, _FILE_AND_LINE_);
RakNet::BitStream bsIn(packet->data, packet->length, false);
bsIn.IgnoreBytes(sizeof(MessageID));
RakNetGUID systemToAddGuid;
bsIn.Read(systemToAddGuid);
*thisSystemAccepted = systemToAddGuid == rakPeerInterface->GetMyGUID();
unsigned short listSize;
bsIn.Read(listSize);
bsIn.IgnoreBytes(listSize*RakNetGUID::size());
bsIn.Read(listSize);
if (systemToAddGuid==rakPeerInterface->GetMyGUID())
{
for (unsigned short i=0; i < listSize; i++)
{
bsIn.Read(systemToAddGuid);
systemsAccepted.Push(systemToAddGuid, _FILE_AND_LINE_);
}
systemsAccepted.Push(packet->guid, _FILE_AND_LINE_);
}
else
{
systemsAccepted.Push(systemToAddGuid, _FILE_AND_LINE_);
bsIn.IgnoreBytes(listSize*RakNetGUID::size());
}
if (additionalData)
{
additionalData->Reset();
additionalData->Write(bsIn);
}
}
示例2: GetMemberIndexToSwitchTeams
unsigned int TeamBalancer::GetMemberIndexToSwitchTeams(const DataStructures::List<TeamId> &sourceTeamNumbers, TeamId targetTeamNumber)
{
DataStructures::List<unsigned int> preferredSwapIndices;
DataStructures::List<unsigned int> potentialSwapIndices;
unsigned int i,j;
for (j=0; j < sourceTeamNumbers.Size(); j++)
{
RakAssert(sourceTeamNumbers[j]!=targetTeamNumber);
for (i=0; i < teamMembers.Size(); i++)
{
if (teamMembers[i].currentTeam==sourceTeamNumbers[j])
{
if (teamMembers[i].requestedTeam==targetTeamNumber)
preferredSwapIndices.Push(i,_FILE_AND_LINE_);
else
potentialSwapIndices.Push(i,_FILE_AND_LINE_);
}
}
}
if (preferredSwapIndices.Size()>0)
{
return preferredSwapIndices[ randomMT() % preferredSwapIndices.Size() ];
}
else if (potentialSwapIndices.Size()>0)
{
return potentialSwapIndices[ randomMT() % potentialSwapIndices.Size() ];
}
else
{
return (unsigned int) -1;
}
}
示例3: CloseUnreferencedSessions
void SQLiteServerLoggerPlugin::CloseUnreferencedSessions(void)
{
DataStructures::List<sqlite3 *> sessionNames;
unsigned int j;
for (j=0; j < loggedInSessions.Size(); j++)
{
if (sessionNames.GetIndexOf(loggedInSessions[j].referencedPointer)==-1)
sessionNames.Push(loggedInSessions[j].referencedPointer, _FILE_AND_LINE_ );
}
DataStructures::List<sqlite3*> unreferencedHandles;
bool isReferenced;
for (unsigned int i=0; i < dbHandles.GetSize(); i++)
{
if (dbHandles[i].dbAutoCreated)
{
j=0;
isReferenced=false;
for (j=0; j < sessionNames.Size(); j++)
{
if (sessionNames[j]==dbHandles[i].dbHandle)
{
isReferenced=true;
break;
}
}
if (isReferenced==false)
{
unreferencedHandles.Push(dbHandles[i].dbHandle,_FILE_AND_LINE_);
}
}
}
if (unreferencedHandles.Size())
{
sqlLoggerThreadPool.LockInput();
if (sqlLoggerThreadPool.HasInputFast()==false)
{
RakSleep(100);
while (sqlLoggerThreadPool.NumThreadsWorking()>0)
RakSleep(30);
for (unsigned int k=0; k < unreferencedHandles.Size(); k++)
{
RemoveDBHandle(unreferencedHandles[k], true);
}
}
sqlLoggerThreadPool.UnlockInput();
if (dbHandles.GetSize()==0)
StopCPUSQLThreads();
}
}
示例4: ReleaseRoomFromCloud
void ReleaseRoomFromCloud(void)
{
RakNet::CloudKey cloudKey("ComprehensiveGame_Rooms",0);
DataStructures::List<CloudKey> keys;
keys.Push(cloudKey, _FILE_AND_LINE_);
cloudClient->Release(keys, game->masterServerGuid);
}
示例5:
void FullyConnectedMesh2::GetParticipantList(DataStructures::List<RakNetGUID> &participantList)
{
participantList.Clear(true, _FILE_AND_LINE_);
unsigned int i;
for (i=0; i < fcm2ParticipantList.Size(); i++)
participantList.Push(fcm2ParticipantList[i].rakNetGuid, _FILE_AND_LINE_);
}
示例6: GetUniqueKeyList
void StatisticsHistory::GetUniqueKeyList(DataStructures::List<RakString> &keys)
{
keys.Clear(true, _FILE_AND_LINE_);
for (unsigned int idx=0; idx < objects.Size(); idx++)
{
TrackedObject *to = objects[idx];
DataStructures::List<TimeAndValueQueue*> itemList;
DataStructures::List<RakNet::RakString> keyList;
to->dataQueues.GetAsList(itemList, keyList, _FILE_AND_LINE_);
for (unsigned int k=0; k < keyList.Size(); k++)
{
bool hasKey=false;
for (unsigned int j=0; j < keys.Size(); j++)
{
if (keys[j]==keyList[k])
{
hasKey=true;
break;
}
}
if (hasKey==false)
keys.Push(keyList[k], _FILE_AND_LINE_);
}
}
}
示例7: GetOverpopulatedTeams
void TeamBalancer::GetOverpopulatedTeams(DataStructures::List<TeamId> &overpopulatedTeams, int maxTeamSize)
{
overpopulatedTeams.Clear(true,_FILE_AND_LINE_);
for (TeamId i=0; i < teamMemberCounts.Size(); i++)
{
if (teamMemberCounts[i]>=maxTeamSize)
overpopulatedTeams.Push(i,_FILE_AND_LINE_);
}
}
示例8: GetHistorySorted
bool StatisticsHistory::GetHistorySorted(uint64_t objectId, SHSortOperation sortType, DataStructures::List<StatisticsHistory::TimeAndValueQueue *> &values) const
{
unsigned int idx = GetObjectIndex(objectId);
if (idx == (unsigned int) -1)
return false;
TrackedObject *to = objects[idx];
DataStructures::List<TimeAndValueQueue*> itemList;
DataStructures::List<RakString> keyList;
to->dataQueues.GetAsList(itemList,keyList,_FILE_AND_LINE_);
Time curTime = GetTime();
DataStructures::OrderedList<TimeAndValueQueue*, TimeAndValueQueue*,TimeAndValueQueueCompAsc> sortedQueues;
for (unsigned int i=0; i < itemList.Size(); i++)
{
TimeAndValueQueue *tavq = itemList[i];
tavq->CullExpiredValues(curTime);
if (sortType == SH_SORT_BY_RECENT_SUM_ASCENDING || sortType == SH_SORT_BY_RECENT_SUM_DESCENDING)
tavq->sortValue = tavq->GetRecentSum();
else if (sortType == SH_SORT_BY_LONG_TERM_SUM_ASCENDING || sortType == SH_SORT_BY_LONG_TERM_SUM_DESCENDING)
tavq->sortValue = tavq->GetLongTermSum();
else if (sortType == SH_SORT_BY_RECENT_SUM_OF_SQUARES_ASCENDING || sortType == SH_SORT_BY_RECENT_SUM_OF_SQUARES_DESCENDING)
tavq->sortValue = tavq->GetRecentSumOfSquares();
else if (sortType == SH_SORT_BY_RECENT_AVERAGE_ASCENDING || sortType == SH_SORT_BY_RECENT_AVERAGE_DESCENDING)
tavq->sortValue = tavq->GetRecentAverage();
else if (sortType == SH_SORT_BY_LONG_TERM_AVERAGE_ASCENDING || sortType == SH_SORT_BY_LONG_TERM_AVERAGE_DESCENDING)
tavq->sortValue = tavq->GetLongTermAverage();
else if (sortType == SH_SORT_BY_RECENT_HIGHEST_ASCENDING || sortType == SH_SORT_BY_RECENT_HIGHEST_DESCENDING)
tavq->sortValue = tavq->GetRecentHighest();
else if (sortType == SH_SORT_BY_RECENT_LOWEST_ASCENDING || sortType == SH_SORT_BY_RECENT_LOWEST_DESCENDING)
tavq->sortValue = tavq->GetRecentLowest();
else if (sortType == SH_SORT_BY_LONG_TERM_HIGHEST_ASCENDING || sortType == SH_SORT_BY_LONG_TERM_HIGHEST_DESCENDING)
tavq->sortValue = tavq->GetLongTermHighest();
else
tavq->sortValue = tavq->GetLongTermLowest();
if (
sortType == SH_SORT_BY_RECENT_SUM_ASCENDING ||
sortType == SH_SORT_BY_LONG_TERM_SUM_ASCENDING ||
sortType == SH_SORT_BY_RECENT_SUM_OF_SQUARES_ASCENDING ||
sortType == SH_SORT_BY_RECENT_AVERAGE_ASCENDING ||
sortType == SH_SORT_BY_LONG_TERM_AVERAGE_ASCENDING ||
sortType == SH_SORT_BY_RECENT_HIGHEST_ASCENDING ||
sortType == SH_SORT_BY_RECENT_LOWEST_ASCENDING ||
sortType == SH_SORT_BY_LONG_TERM_HIGHEST_ASCENDING ||
sortType == SH_SORT_BY_LONG_TERM_LOWEST_ASCENDING)
sortedQueues.Insert(tavq, tavq, false, _FILE_AND_LINE_, TimeAndValueQueueCompAsc);
else
sortedQueues.Insert(tavq, tavq, false, _FILE_AND_LINE_, TimeAndValueQueueCompDesc);
}
for (unsigned int i=0; i < sortedQueues.Size(); i++)
values.Push(sortedQueues[i], _FILE_AND_LINE_);
return true;
}
示例9: PostRoomToCloud
// Upload details about the current game state to the cloud
// This is the responsibility of the system that initially created that room.
// If that system disconnects, the new host, as determined by FullyConnectedMesh2 will reupload the room
void PostRoomToCloud(void)
{
BitStream bsOut;
DataStructures::List<NATTypeDetectionResult> natTypes;
for (unsigned int i=0; i < game->users.Size(); i++)
natTypes.Push(game->users[i]->natType, _FILE_AND_LINE_);
SerializeToBitStream(&bsOut, game->gameName, natTypes);
RakNet::CloudKey cloudKey("ComprehensiveGame_Rooms",0);
cloudClient->Post(&cloudKey, bsOut.GetData(), bsOut.GetNumberOfBytesUsed(), game->masterServerGuid);
printf("Posted game session. In room.\n");
}
示例10: GetJoinsInProgressIndex
void FullyConnectedMesh2::GetVerifiedJoinRequiredProcessingList(RakNetGUID host, DataStructures::List<SystemAddress> &addresses, DataStructures::List<RakNetGUID> &guids)
{
addresses.Clear(true, _FILE_AND_LINE_);
guids.Clear(true, _FILE_AND_LINE_);
unsigned int curIndex = GetJoinsInProgressIndex(host);
if (curIndex!=(unsigned int) -1)
{
VerifiedJoinInProgress *vjip = joinsInProgress[curIndex];
unsigned int j;
for (j=0; j < vjip->members.Size(); j++)
{
if (vjip->members[j].joinInProgressState==JIPS_PROCESSING)
{
addresses.Push(vjip->members[j].systemAddress, _FILE_AND_LINE_);
guids.Push(vjip->members[j].guid, _FILE_AND_LINE_);
}
}
}
}
示例11: GetVerifiedJoinInProgressMemberIndex
void FullyConnectedMesh2::CategorizeVJIP(VerifiedJoinInProgress *vjip,
DataStructures::List<RakNetGUID> &participatingMembersOnClientSucceeded,
DataStructures::List<RakNetGUID> &participatingMembersOnClientFailed,
DataStructures::List<RakNetGUID> &participatingMembersNotOnClient,
DataStructures::List<RakNetGUID> &clientMembersNotParticipatingSucceeded,
DataStructures::List<RakNetGUID> &clientMembersNotParticipatingFailed)
{
for (unsigned int i=0; i < vjip->members.Size(); i++)
vjip->members[i].workingFlag=false;
for (unsigned int i=0; i < fcm2ParticipantList.Size(); i++)
{
unsigned int j = GetVerifiedJoinInProgressMemberIndex(fcm2ParticipantList[i].rakNetGuid, vjip);
if (j==(unsigned int)-1)
{
participatingMembersNotOnClient.Push(fcm2ParticipantList[i].rakNetGuid, _FILE_AND_LINE_);
}
else
{
if (vjip->members[j].joinInProgressState==JIPS_FAILED)
participatingMembersOnClientFailed.Push(fcm2ParticipantList[i].rakNetGuid, _FILE_AND_LINE_);
else
participatingMembersOnClientSucceeded.Push(fcm2ParticipantList[i].rakNetGuid, _FILE_AND_LINE_);
vjip->members[j].workingFlag=true;
}
}
for (unsigned int j=0; j < vjip->members.Size(); j++)
{
if (vjip->members[j].workingFlag==false)
{
if (vjip->members[j].joinInProgressState==JIPS_FAILED)
clientMembersNotParticipatingFailed.Push(vjip->members[j].guid, _FILE_AND_LINE_);
else
clientMembersNotParticipatingSucceeded.Push(vjip->members[j].guid, _FILE_AND_LINE_);
}
}
}
示例12: DeserializeFromBitStream
// Read roomName and a list of NATTypeDetectionResult from a bitStream
void DeserializeFromBitStream(RakNet::CloudQueryRow *row, RakString &roomName, DataStructures::List<NATTypeDetectionResult> &natTypes)
{
RakNet::BitStream bsIn(row->data, row->length, false);
bsIn.Read(roomName);
unsigned short natTypesCount;
bsIn.Read(natTypesCount);
for (unsigned short i=0; i < natTypesCount; i++)
{
NATTypeDetectionResult ntdr;
bsIn.ReadCasted<unsigned char>(ntdr);
natTypes.Push(ntdr, _FILE_AND_LINE_);
}
}
示例13: MoveMemberThatWantsToJoinTeamInternal
TeamId TeamBalancer::MoveMemberThatWantsToJoinTeamInternal(TeamId teamId)
{
DataStructures::List<TeamId> membersThatWantToJoinTheTeam;
for (TeamId i=0; i < teamMembers.Size(); i++)
{
if (teamMembers[i].requestedTeam==teamId)
membersThatWantToJoinTheTeam.Push(i,_FILE_AND_LINE_);
}
if (membersThatWantToJoinTheTeam.Size()>0)
{
TeamId oldTeam;
unsigned int swappedMemberIndex = membersThatWantToJoinTheTeam[ randomMT() % membersThatWantToJoinTheTeam.Size() ];
oldTeam=teamMembers[swappedMemberIndex].currentTeam;
SwitchMemberTeam(swappedMemberIndex,teamId);
NotifyTeamAssigment(swappedMemberIndex);
return oldTeam;
}
return UNASSIGNED_TEAM_ID;
}
示例14: WriteToTable
void ServerAndRoomBrowserData::WriteToTable(DataStructures::Table *table)
{
table->Clear();
DataStructures::Table::Cell cells[4];
table->AddColumn("numPlayers", DataStructures::Table::NUMERIC);
cells[0].Set((unsigned int) numPlayers);
table->AddColumn("maxPlayers", DataStructures::Table::NUMERIC);
cells[1].Set((unsigned int) maxPlayers);
table->AddColumn("mapName", DataStructures::Table::STRING);
cells[2].Set(mapName.C_String());
table->AddColumn("roomName", DataStructures::Table::STRING); // "Room name" from RoomTypes.cpp, write this here?
cells[3].Set(roomName.C_String());
// The rooms plugin uses this table, and the rooms plugin automatically assigns a room id
// table->AddColumn(DefaultRoomColumns::GetColumnName(DefaultRoomColumns::TC_ROOM_ID), DataStructures::Table::NUMERIC);
// cells[4].Set((double) roomId.g);
RakAssert(table->GetColumnCount()==4);
DataStructures::List<DataStructures::Table::Cell*> initialCellValues;
for (int i=0; i < 4; i++)
initialCellValues.Push(&cells[i],_FILE_AND_LINE_);
table->AddRow(table->GetRowCount(), initialCellValues, true);
}
示例15: if
HTTPReadResult PHPDirectoryServer2::ProcessHTTPRead(RakNet::RakString httpRead)
{
const char *c = (const char*) httpRead.C_String(); // current position
HTTPReadResult resultCode=HTTP_RESULT_EMPTY;
lastDownloadedTable.Clear();
if (*c=='\n')
c++;
char buff[256];
int buffIndex;
bool isCommand=true;
DataStructures::List<RakNet::RakString> columns;
DataStructures::List<RakNet::RakString> values;
RakNet::RakString curString;
bool isComment=false;
buffIndex=0;
while(c && *c)
{
// 3 is comment
if (*c=='\003')
{
isComment=!isComment;
c++;
continue;
}
if (isComment)
{
c++;
continue;
}
// 1 or 2 separates fields
// 4 separates rows
if (*c=='\001')
{
if (isCommand)
{
buff[buffIndex]=0;
columns.Push(RakString::NonVariadic(buff), _FILE_AND_LINE_);
isCommand=false;
if (buff[0]!=0)
resultCode=HTTP_RESULT_GOT_TABLE;
}
else
{
buff[buffIndex]=0;
values.Push(RakString::NonVariadic(buff), _FILE_AND_LINE_);
isCommand=true;
}
buffIndex=0;
}
else if (*c=='\002')
{
buff[buffIndex]=0;
buffIndex=0;
values.Push(RakString::NonVariadic(buff), _FILE_AND_LINE_);
isCommand=true;
PushColumnsAndValues(columns, values);
columns.Clear(true, _FILE_AND_LINE_);
values.Clear(true, _FILE_AND_LINE_);
}
else
{
if (buffIndex<256-1)
buff[buffIndex++]=*c;
}
c++;
}
if (buff[0] && columns.Size()==values.Size()+1)
{
buff[buffIndex]=0;
values.Push(RakString::NonVariadic(buff), _FILE_AND_LINE_);
}
PushColumnsAndValues(columns, values);
return resultCode;
}