本文整理汇总了C++中TABLE类的典型用法代码示例。如果您正苦于以下问题:C++ TABLE类的具体用法?C++ TABLE怎么用?C++ TABLE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TABLE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert
void TABLE::insert(SYM *sp)
{
int nn;
TypeArray *ta = sp->GetProtoTypes();
TABLE *tab = this;
SYM *p;
int s1,s2,s3;
std::string nm;
// std::string sig;
if (sp == nullptr || this == nullptr ) {
dfs.printf("Null pointer at insert\n");
throw new C64PException(ERR_NULLPOINTER,1);
}
if (this==&tagtable) {
dfs.printf("Insert into tagtable:%s|\n",(char *)sp->name->c_str());
}
else
dfs.printf("Insert %s into %p", (char *)sp->name->c_str(), (char *)this);
dfs.printf("(%s)\n",owner ? (char *)SYM::GetPtr(owner)->name->c_str(): (char *)"");
// sig = sp->BuildSignature();
if (tab==&gsyms[0]) {
dfs.printf("Insert into global table\n");
s1 = hashadd((char *)sp->name->c_str());
s2 = hashadd((char *)sp->name2->c_str());
s3 = hashadd((char *)sp->name3->c_str());
// tab = &gsyms[(s1&s2)|(s1&s3)|(s2&s3)];
tab = &gsyms[s1];
}
nm = *sp->name;
// The symbol may not have a type if it's just a label. Find doens't
// look at the return type parameter anyway, so we just set it to bt_long
// if tp isn't set.
nn = tab->Find(nm,sp->tp ? sp->tp->typeno : bt_long,ta,true);
if(nn == 0) {
if( tab->head == 0) {
tab->SetHead(sp->GetIndex());
tab->SetTail(sp->GetIndex());
}
else {
sp->GetPtr(tab->tail)->next = sp->GetIndex();
tab->SetTail(sp->GetIndex());
}
sp->SetNext(0);
dfs.printf("At insert:\n");
sp->GetProtoTypes()->Print();
}
else
error(ERR_DUPSYM);
if (ta)
delete ta;
// p = tab->GetHead();
// while(p) {
// printf("Xele:%p|%s|\r\n", p, p->name.c_str());
// p = p->GetNext();
// }
}
示例2: create
void create(ClientMap& clientMap, char ID[], char plainPwd[], TABLE& id_table)
{
//clientMap.showMap();
if(clientMap.search(ID) != nullptr) {
printf("ID %s exists, ", ID);
// show 10 unused ID
int count = 0;
NextWordGenerator gen(ID);
while(count != 10)
{
char *next = gen.getNext();
if(clientMap.search(next) == nullptr) // if the ID doesn't exist, show it
{
printf("%s%c", next, (count == 9) ? '\n' : ',');
count++;
}
}
return;
}
int pos = id_table.insert(ID);
char encryptedPwd[110]; md5(encryptedPwd, plainPwd);
clientMap.insert(ID, encryptedPwd, pos);
printf("success\n");
return;
}
示例3: merge
void merge(ClientMap& clientMap, char ID[], char password[], char ID_2[], char password_2[], TABLE &id_table)
{
ClientData *clientData_1 = clientMap.search(ID);
ClientData *clientData_2 = clientMap.search(ID_2);
if (clientData_1 == nullptr){
printf("ID %s not found\n", ID);
return;
}
if (clientData_2 == nullptr){
printf("ID %s not found\n", ID_2);
return;
}
char encryptedPwd_1[110]; md5(encryptedPwd_1, password);
if (strcmp(clientData_1->md5_password, encryptedPwd_1) != 0){
printf("wrong password1\n");
return;
}
char encryptedPwd_2[110]; md5(encryptedPwd_2, password_2);
if (strcmp(clientData_2->md5_password, encryptedPwd_2) != 0){
printf("wrong password2\n");
return;
}
clientData_1->money += clientData_2->money;
mergeHistory(clientData_1->history, clientData_2->history);
char* tempID = id_table.eraser(clientData_2->IDpos, strlen(ID_2));
if (tempID != NULL){
ClientData *backID_clientData = clientMap.search(tempID);
backID_clientData->IDpos = clientData_2->IDpos;
}
clientMap.erase(ID_2);
printf("success, %s has %lld dollars\n", ID, clientData_1->money);
return;
}
示例4: remove
void remove(ClientMap& clientMap, char ID[], char plainPwd[], TABLE &id_table)
{
ClientData *clientData = clientMap.search(ID);
if (clientData == nullptr){
printf("ID %s not found\n", ID);
return;
}
char encryptedPwd[110]; md5(encryptedPwd, plainPwd);
if (strcmp(clientData->md5_password, encryptedPwd) == 0){
char* tempID = id_table.eraser(clientData->IDpos, strlen(ID));
if (tempID != NULL){
ClientData *clientData_2 = clientMap.search(tempID);
clientData_2->IDpos = clientData->IDpos;
}
clientMap.erase(ID);
printf("success\n");
}
else
printf("wrong password\n");
}
示例5: transfer
void transfer(ClientMap& clientMap, char ID[], char transferID[], LLI money, TABLE& id_table)
{
ClientData *clientData = clientMap.search(ID);
ClientData *transferData = clientMap.search(transferID);
if (transferData == nullptr){
id_table.recommendID(transferID);
return;
}
if (clientData->money < money){
printf("fail, %lld dollars only in current account\n", clientData->money);
return;
}
clientData->money -= money;
transferData->money += money;
transferHistory(clientData->history, ID, transferData->history, transferID, timeStamp, money);
timeStamp++;
printf("success, %lld dollars left in current account\n", clientData->money);
}
示例6: ParseEnumDeclaration
void ParseEnumDeclaration(TABLE *table)
{
SYM *sp;
TYP *tp;
if( lastst == id) {
if((sp = search(lastid,&tagtable)) == NULL) {
sp = allocSYM();
sp->tp = TYP::Make(bt_enum,1);
sp->storage_class = sc_type;
sp->SetName(*(new std::string(lastid)));
sp->tp->sname = new std::string(*sp->name);
NextToken();
if( lastst != begin)
error(ERR_INCOMPLETE);
else {
tagtable.insert(sp);
NextToken();
ParseEnumerationList(table);
}
}
else
NextToken();
head = sp->tp;
}
else {
tp = allocTYP(); // fix here
tp->type = bt_enum;
tp->size = 1;
if( lastst != begin)
error(ERR_INCOMPLETE);
else {
NextToken();
ParseEnumerationList(table);
}
head = tp;
}
}
示例7: MyMPI_ExchangeTable
inline void MyMPI_ExchangeTable (TABLE<T> & send_data,
TABLE<T> & recv_data, int tag,
MPI_Comm comm = MPI_COMM_WORLD)
{
int ntasks, rank;
MPI_Comm_size(comm, &ntasks);
MPI_Comm_rank(comm, &rank);
Array<int> send_sizes(ntasks);
Array<int> recv_sizes(ntasks);
for (int i = 0; i < ntasks; i++)
send_sizes[i] = send_data[i].Size();
MPI_Alltoall (&send_sizes[0], 1, MPI_INT,
&recv_sizes[0], 1, MPI_INT, comm);
// in-place is buggy !
// MPI_Alltoall (MPI_IN_PLACE, 1, MPI_INT,
// &recv_sizes[0], 1, MPI_INT, comm);
for (int i = 0; i < ntasks; i++)
recv_data.SetEntrySize (i, recv_sizes[i], sizeof(T));
Array<MPI_Request> requests;
for (int dest = 0; dest < ntasks; dest++)
if (dest != rank && send_data[dest].Size())
requests.Append (MyMPI_ISend (send_data[dest], dest, tag, comm));
for (int dest = 0; dest < ntasks; dest++)
if (dest != rank && recv_data[dest].Size())
requests.Append (MyMPI_IRecv (recv_data[dest], dest, tag, comm));
// MPI_Barrier (comm);
MPI_Waitall (requests.Size(), &requests[0], MPI_STATUS_IGNORE);
}
示例8: Position
int Position (int bnr, const INDEX_2 & ind) const
{
for (int i = 1; i <= hash.EntrySize (bnr); i++)
if (hash.Get(bnr, i) == ind)
return i;
return 0;
}
示例9: Set
void Set (const INDEX_2 & ahash, const T & acont)
{
int bnr = HashValue (ahash);
int pos = Position (bnr, ahash);
if (pos)
cont.Set (bnr, pos, acont);
else
{
hash.Add1 (bnr, ahash);
cont.Add1 (bnr, acont);
}
}
示例10: PrintMemInfo
void PrintMemInfo (ostream & ost) const
{
ost << "Hash: " << endl;
hash.PrintMemInfo (ost);
ost << "Cont: " << endl;
cont.PrintMemInfo (ost);
}
示例11: GetOCPTSize
//outerchartspertrig, sorted!
int GetOCPTSize() const {return outerchartspertrig.Size();};
示例12: AddEdgePP
void AddEdgePP(int pn, int vn) {edgesperpoint.Add1(pn,vn);};
示例13: GetEdgePP
int GetEdgePP(int pn, int vi)
{
if (edgesperpoint.Size() == 0) {BuildEdgesPerPoint();}
return edgesperpoint.Get(pn,vi);
};
示例14: GetNEPP
int GetNEPP(int pn)
{
if (edgesperpoint.Size() == 0) {BuildEdgesPerPoint();}
return edgesperpoint.EntrySize(pn);
};
示例15: GetEPPSize
//get NO edges per point
int GetEPPSize() const {return edgesperpoint.Size();};