本文整理汇总了C++中datastructures::List类的典型用法代码示例。如果您正苦于以下问题:C++ List类的具体用法?C++ List怎么用?C++ List使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了List类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnConnectionRequestAccepted
PluginReceiveResult NatPunchthrough::OnConnectionRequestAccepted(Packet *packet)
{
unsigned i;
i=0;
while (i < connectionRequestList.Size())
{
DataStructures::List<SystemAddress> fallbackAddresses;
connectionRequestList[i]->GetAddressList(rakPeer, fallbackAddresses, connectionRequestList[i]->receiverPublic, connectionRequestList[i]->receiverPrivate, false);
if (fallbackAddresses.GetIndexOf(packet->systemAddress)!=(unsigned) -1)
{
rakFree(connectionRequestList[i]->passwordData);
delete connectionRequestList[i];
connectionRequestList.RemoveAtIndex(i);
return RR_CONTINUE_PROCESSING;
}
i++;
}
// return to user
return RR_CONTINUE_PROCESSING;
}
示例2: Get
bool CloudClient::Get(CloudQuery *keyQuery, DataStructures::List<CloudQueryRow*> &specificSystems, RakNetGUID systemIdentifier)
{
RakNet::BitStream bsOut;
bsOut.Write((MessageID)ID_CLOUD_GET_REQUEST);
keyQuery->Serialize(true, &bsOut);
bsOut.WriteCasted<uint16_t>(specificSystems.Size());
RakAssert(specificSystems.Size() < (uint16_t)-1 );
for (uint16_t i=0; i < specificSystems.Size(); i++)
{
if (specificSystems[i]->clientGUID!=UNASSIGNED_RAKNET_GUID)
{
bsOut.Write(true);
bsOut.Write(specificSystems[i]->clientGUID);
}
else
{
bsOut.Write(false);
bsOut.Write(specificSystems[i]->clientSystemAddress);
}
}
SendUnified(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, systemIdentifier, false);
return true;
}
示例3:
void PHPDirectoryServer2::PushColumnsAndValues(DataStructures::List<RakNet::RakString> &columns, DataStructures::List<RakNet::RakString> &values)
{
DataStructures::Table::Row *row=0;
unsigned int i;
for (i=0; i < columns.Size() && i < values.Size(); i++)
{
if (columns[i].IsEmpty()==false)
{
unsigned col = lastDownloadedTable.ColumnIndex(columns[i]);
if(col == (unsigned)-1)
{
col = lastDownloadedTable.AddColumn(columns[i], DataStructures::Table::STRING);
}
if (row==0)
{
row = lastDownloadedTable.AddRow(lastDownloadedTable.GetAvailableRowId());
}
row->UpdateCell(col,values[i].C_String());
}
}
}
示例4: SerializeRow
void TableSerializer::SerializeRow(DataStructures::Table::Row *in, unsigned keyIn, DataStructures::List<DataStructures::Table::ColumnDescriptor> &columns, RakNet::BitStream *out, DataStructures::List<int> &skipColumnIndices)
{
unsigned cellIndex;
out->Write(keyIn);
unsigned int numEntries=0;
for (cellIndex=0; cellIndex<columns.Size(); cellIndex++)
{
if (skipColumnIndices.GetIndexOf(cellIndex)==(unsigned)-1)
{
numEntries++;
}
}
out->Write(numEntries);
for (cellIndex=0; cellIndex<columns.Size(); cellIndex++)
{
if (skipColumnIndices.GetIndexOf(cellIndex)==(unsigned)-1)
{
out->Write(cellIndex);
SerializeCell(out, in->cells[cellIndex], columns[cellIndex].columnType);
}
}
}
示例5: GetCommandListReplicaIndex
unsigned ReplicaManager::GetCommandListReplicaIndex(const DataStructures::List<ReplicaManager::CommandStruct> &commandList, Replica *replica, bool *objectExists) const
{
unsigned i;
for (i=0; i < commandList.Size(); i++)
{
if (commandList[i].replica==replica)
{
*objectExists=true;
return i;
}
}
*objectExists=false;
return 0;
}
示例6:
void FullyConnectedMesh2::GetHostOrder(DataStructures::List<RakNetGUID> &hostList)
{
hostList.Clear(true, _FILE_AND_LINE_);
if (ourFCMGuid==0 || fcm2ParticipantList.Size()==0)
{
hostList.Push(rakPeerInterface->GetMyGUID(), _FILE_AND_LINE_);
return;
}
FCM2Participant fcm2;
fcm2.fcm2Guid=ourFCMGuid;
fcm2.rakNetGuid=rakPeerInterface->GetMyGUID();
DataStructures::OrderedList<FCM2Participant, FCM2Participant, FCM2ParticipantComp> olist;
olist.Insert(fcm2, fcm2, true, _FILE_AND_LINE_);
for (unsigned int i=0; i < fcm2ParticipantList.Size(); i++)
olist.Insert(fcm2ParticipantList[i], fcm2ParticipantList[i], true, _FILE_AND_LINE_);
for (unsigned int i=0; i < olist.Size(); i++)
{
hostList.Push(olist[i].rakNetGuid, _FILE_AND_LINE_);
}
}
示例7: enter
void ServerState::enter()
{
// console setup
GG.console->clear();
GG.gui.attach(GG.console);
// raknet
mServer = RakNetworkFactory::GetRakPeerInterface();
mServer->SetIncomingPassword("Rumpelstiltskin", (int)strlen("Rumpelstiltskin"));
mSocketDesc = SocketDescriptorPtr(new SocketDescriptor(SERVER_PORT, 0));
bool b = mServer->Startup(4, 30, mSocketDesc.get(), 1);
mServer->SetMaximumIncomingConnections(4);
mServer->SetOccasionalPing(true);
mServer->SetUnreliableTimeout(1000);
GuiConsoleOutput cout = GG.console->output();
cout << "Wargame server" << endl;
cout << "local IP: " << mServer->GetLocalIP(0) << endl;
cout << "GUID: " << mServer->GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS).ToString() << endl;
DataStructures::List<RakNetSmartPtr<RakNetSocket> > sockets;
mServer->GetSockets(sockets);
cout << "Ports used by RakNet:\n";
for (unsigned int i=0; i < sockets.Size(); i++) {
cout << i+1 << " " << sockets[i]->boundAddress.port << endl;
}
cout.flush();
// console callback invoked on text input
GG.console->slot("textInput", GuiCallbackPtr(new ServerConsoleInput(GG, *this)));
// network classes
mGameClient = WargameClientPtr(new WargameClient());
mGameServer = WargameServerPtr(new WargameServer());
}
示例8: DeleteFilterSet
void MessageFilter::DeleteFilterSet(int filterSetID)
{
FilterSet *filterSet;
bool objectExists;
unsigned i,index;
index = filterList.GetIndexFromKey(filterSetID, &objectExists);
if (objectExists)
{
filterSet=filterList[index];
DeallocateFilterSet(filterSet);
filterList.RemoveAtIndex(index);
DataStructures::List< FilteredSystem > itemList;
DataStructures::List< AddressOrGUID > keyList;
systemList.GetAsList(itemList, keyList, _FILE_AND_LINE_);
for (i=0; i < itemList.Size(); i++)
{
if (itemList[i].filter==filterSet)
{
systemList.Remove(keyList[i], _FILE_AND_LINE_);
}
}
/*
// Don't reference this pointer any longer
i=0;
while (i < systemList.Size())
{
if (systemList[i].filter==filterSet)
systemList.RemoveAtIndex(i);
else
++i;
}
*/
}
}
示例9: OpenNATGroup
bool NatPunchthroughClient::OpenNATGroup(DataStructures::List<RakNetGUID> destinationSystems, const SystemAddress &facilitator)
{
ConnectionState cs = rakPeerInterface->GetConnectionState(facilitator);
if (cs!=IS_CONNECTED)
return false;
unsigned long i;
for (i=0; i < destinationSystems.Size(); i++)
{
SendPunchthrough(destinationSystems[i], facilitator);
}
GroupPunchRequest *gpr = RakNet::OP_NEW<GroupPunchRequest>(_FILE_AND_LINE_);
gpr->facilitator=facilitator;
gpr->pendingList=destinationSystems;
groupPunchRequests.Push(gpr, _FILE_AND_LINE_);
return true;
}
示例10:
PluginReceiveResult FullyConnectedMesh2::OnVerifiedJoinCapable(Packet *packet)
{
VerifiedJoinInProgress vjip;
DecomposeJoinCapable(packet, &vjip);
// If this assert hits, AddParticipant() was called on this system, or another system, which it should not have been.
RakAssert(HasParticipant(packet->guid)==false);
DataStructures::List<RakNetGUID> participatingMembersOnClientSucceeded;
DataStructures::List<RakNetGUID> participatingMembersOnClientFailed;
DataStructures::List<RakNetGUID> participatingMembersNotOnClient;
DataStructures::List<RakNetGUID> clientMembersNotParticipatingSucceeded;
DataStructures::List<RakNetGUID> clientMembersNotParticipatingFailed;
CategorizeVJIP(&vjip,
participatingMembersOnClientSucceeded,
participatingMembersOnClientFailed,
participatingMembersNotOnClient,
clientMembersNotParticipatingSucceeded,
clientMembersNotParticipatingFailed);
if (participatingMembersOnClientFailed.Size()>0)
{
// Send ID_FCM2_VERIFIED_JOIN_FAILED with GUIDs to disconnect
BitStream bsOut;
bsOut.Write((MessageID) ID_FCM2_VERIFIED_JOIN_FAILED);
SendUnified(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, packet->guid, false);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
}
if (participatingMembersNotOnClient.Size()>0)
{
BitStream bsOut;
bsOut.Write((MessageID) ID_FCM2_VERIFIED_JOIN_START);
bsOut.WriteCasted<unsigned short>(participatingMembersNotOnClient.Size());
unsigned int i;
for (i=0; i < participatingMembersNotOnClient.Size(); i++)
{
bsOut.Write(participatingMembersNotOnClient[i]);
bsOut.Write(rakPeerInterface->GetSystemAddressFromGuid(participatingMembersNotOnClient[i]));
}
SendUnified(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, packet->guid, false);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
}
// Let server decide if to accept or reject via RespondOnVerifiedJoinCapable
return RR_CONTINUE_PROCESSING;
}
示例11: Unsubscribe
void CloudClient::Unsubscribe(DataStructures::List<CloudKey> &keys, DataStructures::List<RakNetGUID> &specificSystems, RakNetGUID systemIdentifier)
{
SLNet::BitStream bsOut;
bsOut.Write((MessageID)ID_CLOUD_UNSUBSCRIBE_REQUEST);
RakAssert(keys.Size() < (uint16_t)-1 );
bsOut.WriteCasted<uint16_t>(keys.Size());
for (uint16_t i=0; i < keys.Size(); i++)
{
keys[i].Serialize(true,&bsOut);
}
bsOut.WriteCasted<uint16_t>(specificSystems.Size());
RakAssert(specificSystems.Size() < (uint16_t)-1 );
for (uint16_t i=0; i < specificSystems.Size(); i++)
{
bsOut.Write(specificSystems[i]);
}
SendUnified(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, systemIdentifier, false);
}
示例12: RunTest
/*
What is being done here is having 8 peers all connect to eachother over the max defined connection.
It runs the connect, wait 20 seconds then see the current connections.
Success conditions:
All extra connections Refused.
Failure conditions:
There are more connected than allowed.
The connect function fails, the test is not even done.
GetMaximumIncomingConnections returns wrong value.
RakPeerInterface Functions used, tested indirectly by its use:
Startup
Connect
SetMaximumIncomingConnections
Receive
DeallocatePacket
GetSystemList
RakPeerInterface Functions Explicitly Tested:
SetMaximumIncomingConnections
GetMaximumIncomingConnections
*/
int MaximumConnectTest::RunTest(DataStructures::List<RakString> params,bool isVerbose,bool noPauses)
{
const int peerNum= 8;
const int maxConnections=4;//Max allowed connections for test
RakPeerInterface *peerList[peerNum];//A list of 8 peers
Packet *packet;
destroyList.Clear(false,_FILE_AND_LINE_);
int connReturn;
//Initializations of the arrays
for (int i=0;i<peerNum;i++)
{
peerList[i]=RakPeerInterface::GetInstance();
destroyList.Push(peerList[i],_FILE_AND_LINE_);
peerList[i]->Startup(maxConnections, &SocketDescriptor(60000+i,0), 1);
peerList[i]->SetMaximumIncomingConnections(maxConnections);
connReturn=peerList[i]->GetMaximumIncomingConnections();
if (connReturn!=maxConnections)
{
if (isVerbose)
{
printf("Getmaxconnections wrong for peer %i, %i should be the value but the value is %i.Fail\n",i,maxConnections,connReturn);
DebugTools::ShowError("",!noPauses && isVerbose,__LINE__,__FILE__);
}
}
}
//Connect all the peers together
for (int i=0;i<peerNum;i++)
{
for (int j=i+1;j<peerNum;j++)//Start at i+1 so don't connect two of the same together.
{
if (peerList[i]->Connect("127.0.0.1", 60000+j, 0,0)!=CONNECTION_ATTEMPT_STARTED)
{
if (isVerbose)
DebugTools::ShowError("Problem while calling connect.\n",!noPauses && isVerbose,__LINE__,__FILE__);
return 1;//This fails the test, don't bother going on.
}
}
}
TimeMS entryTime=GetTimeMS();//Loop entry time
while(GetTimeMS()-entryTime<20000)//Run for 20 Secoonds
{
for (int i=0;i<peerNum;i++)//Receive for all peers
{
packet=peerList[i]->Receive();
if (isVerbose&&packet)
printf("For peer %i\n",i);
while(packet)
{
switch (packet->data[0])
{
//.........这里部分代码省略.........
示例13: main
_CONSOLE_2_SetSystemProcessParams
#endif
int main(void)
{
// Pointers to the interfaces of our server and client.
// Note we can easily have both in the same program
RakPeerInterface *server=RakNetworkFactory::GetRakPeerInterface();
RakNetStatistics *rss;
server->SetIncomingPassword("Rumpelstiltskin", (int)strlen("Rumpelstiltskin"));
server->SetTimeoutTime(30000,UNASSIGNED_SYSTEM_ADDRESS);
// PacketLogger packetLogger;
// server->AttachPlugin(&packetLogger);
// Holds packets
Packet* p;
// GetPacketIdentifier returns this
unsigned char packetIdentifier;
// Record the first client that connects to us so we can pass it to the ping function
SystemAddress clientID=UNASSIGNED_SYSTEM_ADDRESS;
// Holds user data
char portstring[30];
printf("This is a sample implementation of a text based chat server.\n");
printf("Connect to the project 'Chat Example Client'.\n");
printf("Difficulty: Beginner\n\n");
// A server
puts("Enter the server port to listen on");
gets(portstring);
if (portstring[0]==0)
strcpy(portstring, "1234");
puts("Starting server.");
// Starting the server is very simple. 2 players allowed.
// 0 means we don't care about a connectionValidationInteger, and false
// for low priority threads
SocketDescriptor socketDescriptor(atoi(portstring),0);
bool b = server->Startup(4, 30, &socketDescriptor, 1 );
server->SetMaximumIncomingConnections(4);
if (b)
puts("Server started, waiting for connections.");
else
{
puts("Server failed to start. Terminating.");
exit(1);
}
server->SetOccasionalPing(true);
server->SetUnreliableTimeout(1000);
DataStructures::List<RakNetSmartPtr<RakNetSocket> > sockets;
server->GetSockets(sockets);
printf("Ports used by RakNet:\n");
for (unsigned int i=0; i < sockets.Size(); i++)
{
printf("%i. %i\n", i+1, sockets[i]->boundAddress.port);
}
printf("My IP is %s\n", server->GetLocalIP(0));
printf("My GUID is %s\n", server->GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS).ToString());
puts("'quit' to quit. 'stat' to show stats. 'ping' to ping.\n'ban' to ban an IP from connecting.\n'kick to kick the first connected player.\nType to talk.");
char message[2048];
// Loop for input
while (1)
{
// This sleep keeps RakNet responsive
RakSleep(30);
#ifdef _WIN32
if (kbhit())
{
// Notice what is not here: something to keep our network running. It's
// fine to block on gets or anything we want
// Because the network engine was painstakingly written using threads.
gets(message);
if (strcmp(message, "quit")==0)
{
puts("Quitting.");
break;
}
if (strcmp(message, "stat")==0)
{
rss=server->GetStatistics(server->GetSystemAddressFromIndex(0));
StatisticsToString(rss, message, 2);
printf("%s", message);
printf("Ping %i\n", server->GetAveragePing(server->GetSystemAddressFromIndex(0)));
continue;
}
if (strcmp(message, "ping")==0)
{
server->Ping(clientID);
//.........这里部分代码省略.........
示例14: QueryRow
void Table::QueryRow(DataStructures::List<unsigned> &inclusionFilterColumnIndices, DataStructures::List<unsigned> &columnIndicesToReturn, unsigned key, Table::Row* row, FilterQuery *inclusionFilters, Table *result)
{
bool pass=false;
unsigned columnIndex;
unsigned j;
// If no inclusion filters, just add the row
if (inclusionFilterColumnIndices.Size()==0)
{
result->AddRowColumns(key, row, columnIndicesToReturn);
}
else
{
// Go through all inclusion filters. Only add this row if all filters pass.
for (j=0; j<inclusionFilterColumnIndices.Size(); j++)
{
columnIndex=inclusionFilterColumnIndices[j];
if (columnIndex!=(unsigned)-1 && row->cells[columnIndex]->isEmpty==false )
{
if (columns[inclusionFilterColumnIndices[j]].columnType==STRING &&
row->cells[columnIndex]->c==0 ||
inclusionFilters[j].cellValue->c==0 )
continue;
switch (inclusionFilters[j].operation)
{
case QF_EQUAL:
switch(columns[inclusionFilterColumnIndices[j]].columnType)
{
case NUMERIC:
pass=row->cells[columnIndex]->i==inclusionFilters[j].cellValue->i;
break;
case STRING:
pass=strcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c)==0;
break;
case BINARY:
pass=row->cells[columnIndex]->i==inclusionFilters[j].cellValue->i &&
memcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c, row->cells[columnIndex]->i)==0;
break;
case POINTER:
pass=row->cells[columnIndex]->ptr==inclusionFilters[j].cellValue->ptr;
break;
}
break;
case QF_NOT_EQUAL:
switch(columns[inclusionFilterColumnIndices[j]].columnType)
{
case NUMERIC:
pass=row->cells[columnIndex]->i!=inclusionFilters[j].cellValue->i;
break;
case STRING:
pass=strcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c)!=0;
break;
case BINARY:
pass=row->cells[columnIndex]->i==inclusionFilters[j].cellValue->i &&
memcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c, row->cells[columnIndex]->i)==0;
break;
case POINTER:
pass=row->cells[columnIndex]->ptr!=inclusionFilters[j].cellValue->ptr;
break;
}
break;
case QF_GREATER_THAN:
switch(columns[inclusionFilterColumnIndices[j]].columnType)
{
case NUMERIC:
pass=row->cells[columnIndex]->i>inclusionFilters[j].cellValue->i;
break;
case STRING:
pass=strcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c)>0;
break;
case BINARY:
break;
case POINTER:
pass=row->cells[columnIndex]->ptr>inclusionFilters[j].cellValue->ptr;
break;
}
break;
case QF_GREATER_THAN_EQ:
switch(columns[inclusionFilterColumnIndices[j]].columnType)
{
case NUMERIC:
pass=row->cells[columnIndex]->i>=inclusionFilters[j].cellValue->i;
break;
case STRING:
pass=strcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c)>=0;
break;
case BINARY:
break;
case POINTER:
pass=row->cells[columnIndex]->ptr>=inclusionFilters[j].cellValue->ptr;
break;
}
break;
case QF_LESS_THAN:
switch(columns[inclusionFilterColumnIndices[j]].columnType)
{
case NUMERIC:
pass=row->cells[columnIndex]->i<inclusionFilters[j].cellValue->i;
break;
//.........这里部分代码省略.........
示例15: QueryTable
void Table::QueryTable(unsigned *columnIndicesSubset, unsigned numColumnSubset, FilterQuery *inclusionFilters, unsigned numInclusionFilters, unsigned *rowIds, unsigned numRowIDs, Table *result)
{
unsigned i;
DataStructures::List<unsigned> columnIndicesToReturn;
// Clear the result table.
result->Clear();
if (columnIndicesSubset && numColumnSubset>0)
{
for (i=0; i < numColumnSubset; i++)
{
if (columnIndicesSubset[i]>=0 && columnIndicesSubset[i]<columns.Size())
columnIndicesToReturn.Insert(columnIndicesSubset[i]);
}
}
else
{
for (i=0; i < columns.Size(); i++)
columnIndicesToReturn.Insert(i);
}
if (columnIndicesToReturn.Size()==0)
return; // No valid columns specified
for (i=0; i < columnIndicesToReturn.Size(); i++)
{
result->AddColumn(columns[columnIndicesToReturn[i]].columnName,columns[columnIndicesToReturn[i]].columnType);
}
// Get the column indices of the filter queries.
DataStructures::List<unsigned> inclusionFilterColumnIndices;
if (inclusionFilters && numInclusionFilters>0)
{
for (i=0; i < numInclusionFilters; i++)
{
if (inclusionFilters[i].columnName[0])
inclusionFilters[i].columnIndex=ColumnIndex(inclusionFilters[i].columnName);
if (inclusionFilters[i].columnIndex>=0 && inclusionFilters[i].columnIndex<columns.Size())
inclusionFilterColumnIndices.Insert(inclusionFilters[i].columnIndex);
else
inclusionFilterColumnIndices.Insert((unsigned)-1);
}
}
if (rowIds==0 || numRowIDs==0)
{
// All rows
DataStructures::Page<unsigned, Row*, _TABLE_BPLUS_TREE_ORDER> *cur = rows.GetListHead();
while (cur)
{
for (i=0; i < (unsigned)cur->size; i++)
{
QueryRow(inclusionFilterColumnIndices, columnIndicesToReturn, cur->keys[i], cur->data[i], inclusionFilters, result);
}
cur=cur->next;
}
}
else
{
// Specific rows
Row *row;
for (i=0; i < numRowIDs; i++)
{
if (rows.Get(rowIds[i], row))
{
QueryRow(inclusionFilterColumnIndices, columnIndicesToReturn, rowIds[i], row, inclusionFilters, result);
}
}
}
}