LISTPOS OverrideList::InsertBefore(LISTPOS here, OverrideListItem* item) { ERROR2IF(item==NULL, NULL, "OverrideList::InsertBefore - NULL parameter"); //First find the list item at the position we have been given OverrideListItem* pliInsertionPoint=(OverrideListItem*) FindItem(here); //If we have not found it, return -1 if (pliInsertionPoint==NULL) return -1; //Otherwise, call our other function to do the insertion OverrideListItem* pliResult=(OverrideListItem*) InsertBefore(pliInsertionPoint, item); //If we have been returned NULL, then return an error value if (pliResult==NULL) return -1; //Otherwise, find our newly returned list item in the list //and return it return FindPosition(pliResult); }
double Interpolate(double x, const point* vals){ int ind = FindPosition(x); const point* pnt = &vals[ind]; double res = log(exp(pnt->c0*x+pnt->c1)); return res; }
void main() { int a[100]; int n; RandomArray(a,n); PrintArray(a,n); FindPosition(a,n); getch(); }
static void Resolve(Widget w, XawTextPosition pos, int fromx, int width, XawTextPosition *pos_return) { int resWidth, resHeight; Widget source = XawTextGetSource(XtParent(w)); FindPosition(w, pos, fromx, width, False, pos_return, &resWidth, &resHeight); if (*pos_return > GETLASTPOS) *pos_return = GETLASTPOS; }
int main(int argc, char** argv) { int i,j,k; int num,temp; i = 0; while (scanf("%s",szA[i])!= EOF) i++; for (j = 0; j < i; j++) { sscanf(szA[j],"%s",szB[j]); //printf("%s ",szB[j]); } qsort (szA,i,sizeof(szA[0]),cmp);// 脑残了,居然直接写ROW,不一定是满的呀 // for ( j = 0; j < i; j++) // printf("%s ",szA[j]); // printf("\n"); for ( j = 0; j < i; j++) { //printf("%s ",szA[j]); k = FindPosition(szB[j],i); // printf("%d ",k); if (k == 0) { num = strc(szA[k],szA[k+1]); szA[k][num] = '\0'; // printf("%d ",num); printf("%s %s\n",szB[j],szA[k]); } else if (k == i - 1) { num = strc(szA[k-1],szA[k]); szA[k][num] = '\0'; // printf("%d ",num); printf("%s %s\n",szB[j],szA[k]); } else{ num = strc(szA[k-1],szA[k]); if (strc(szA[k],szA[k+1])> num) num = strc(szA[k],szA[k+1]); szA[k][num] = '\0'; //printf("%d ",num); printf("%s %s\n",szB[j],szA[k]); } } return 0; }
/* START: fig5_17.txt */ void Insert( ElementType Key, HashTable H ) { Position Pos; Pos = FindPosition( Key, H ); if( H->TheCells[ Pos ].Info != Legitimate ) { /* OK to insert here */ H->TheCells[ Pos ].Info = Legitimate; H->TheCells[ Pos ].Element = Key; /* Probably need strcpy! */ } }
bool ChannelAgent::RemoveUser(const char* data) { ASSERT(data != NULL); /* * Function purpose: Remove nickname {data} from the ChannelAgent's * NamesView and update the status counts */ if (fNamesList == NULL) return false; // if nickname is present in tab completion lists, remove RemoveNickFromList(fRecentNicks, data); RemoveNickFromList(fCompletionNicks, data); int32 myIndex(FindPosition(data)); if (myIndex >= 0) { NameItem* item; fNamesList->Deselect(myIndex); if ((item = static_cast<NameItem*>(fNamesList->RemoveItem(myIndex))) != NULL) { BString buffer; if ((item->Status() & STATUS_OP_BIT) != 0) { --fOpsCount; buffer << fOpsCount; if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_OPS, buffer.String()); buffer = ""; } --fUserCount; buffer << fUserCount; if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_USERS, buffer.String()); delete item; return true; } } return false; }
static void Resolve( Widget w, XawTextPosition pos, int fromx, int width, XawTextPosition * leftPos, XawTextPosition * rightPos) { int resWidth, resHeight; Widget source = XawTextGetSource(XtParent(w)); FindPosition(w, pos, fromx, width, FALSE, leftPos, &resWidth, &resHeight); if (*leftPos > GETLASTPOS) *leftPos = GETLASTPOS; *rightPos = *leftPos; }
void Mesh::CalcInterpolatedPosition(aiVector3D& Out, float AnimationTime, const aiNodeAnim* pNodeAnim) { if (pNodeAnim->mNumPositionKeys == 1) { Out = pNodeAnim->mPositionKeys[0].mValue; return; } uint PositionIndex = FindPosition(AnimationTime, pNodeAnim); uint NextPositionIndex = (PositionIndex + 1); assert(NextPositionIndex < pNodeAnim->mNumPositionKeys); float DeltaTime = (float)(pNodeAnim->mPositionKeys[NextPositionIndex].mTime - pNodeAnim->mPositionKeys[PositionIndex].mTime); float Factor = (AnimationTime - (float)pNodeAnim->mPositionKeys[PositionIndex].mTime) / DeltaTime; assert(Factor >= 0.0f && Factor <= 1.0f); const aiVector3D& Start = pNodeAnim->mPositionKeys[PositionIndex].mValue; const aiVector3D& End = pNodeAnim->mPositionKeys[NextPositionIndex].mValue; aiVector3D Delta = End - Start; Out = Start + Factor * Delta; }
void ChannelAgent::MessageReceived(BMessage* msg) { int32 i(0); switch (msg->what) { case M_USER_QUIT: { const char* nick(NULL); msg->FindString("nick", &nick); if (RemoveUser(nick)) { BMessage display; if (msg->FindMessage("display", &display) == B_NO_ERROR) ClientAgent::MessageReceived(&display); } } break; case M_USER_ADD: { const char* nick(NULL); bool ignore(false); int32 iStatus(STATUS_NORMAL_BIT); msg->FindString("nick", &nick); msg->FindBool("ignore", &ignore); if (nick == NULL) { printf("ERROR: attempted to AddUser an empty nick in ChannelAgent, channel: %s\n", fId.String()); break; } if (ignore) iStatus |= STATUS_IGNORE_BIT; AddUser(nick, iStatus); BMessage display; if (msg->FindMessage("display", &display) == B_NO_ERROR) ClientAgent::MessageReceived(&display); } break; case M_CHANGE_NICK: { const char* oldNick(NULL), *newNick(NULL); NameItem* item(NULL); int32 thePos(-1); if ((msg->FindString("oldnick", &oldNick) != B_OK) || (msg->FindString("newnick", &newNick) != B_OK)) { printf("Error: invalid pointer, ChannelAgent::MessageReceived, M_CHANGE_NICK"); break; } if (fMyNick.ICompare(oldNick) == 0 && !IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_NICK, newNick); if (((thePos = FindPosition(oldNick)) >= 0) && ((item = (static_cast<NameItem*>(fNamesList->ItemAt(thePos)))) != 0)) { item->SetName(newNick); fNamesList->SortItems(SortNames); if (fLastExpansion.ICompare(oldNick, fLastExpansion.Length()) == 0) { int32 count(fRecentNicks.CountItems()); BString* name(NULL); for (i = 0; i < count; i++) if ((name = fRecentNicks.ItemAt(i))->ICompare(oldNick) == 0) { if (fLastExpansion.ICompare(newNick, fLastExpansion.Length()) == 0) name->SetTo(newNick); else delete fRecentNicks.RemoveItemAt(i); break; } count = fCompletionNicks.CountItems(); for (i = 0; i < count; i++) if ((name = fCompletionNicks.ItemAt(i))->ICompare(oldNick) == 0) { if (fLastExpansion.ICompare(newNick, fLastExpansion.Length()) == 0) name->SetTo(newNick); else delete fCompletionNicks.RemoveItemAt(i); break; } } } else break; ClientAgent::MessageReceived(msg); } break; case M_CHANNEL_NAMES: { for (i = 0; msg->HasString("nick", i); ++i) { const char* nick(NULL); bool founder(false), protect(false), op(false), voice(false), helper(false), ignored(false); msg->FindString("nick", i, &nick); msg->FindBool("founder", i, &founder); msg->FindBool("protect", i, &protect); msg->FindBool("op", i, &op); msg->FindBool("voice", i, &voice); msg->FindBool("helper", i, &helper); msg->FindBool("ignored", i, &ignored); if (FindPosition(nick) < 0) { int32 iStatus(ignored ? STATUS_IGNORE_BIT : 0); if (founder) { ++nick; ++fOpsCount; iStatus |= STATUS_FOUNDER_BIT; } else if (protect) { ++nick; ++fOpsCount; iStatus |= STATUS_PROTECTED_BIT; } else if (op) { ++nick; ++fOpsCount; iStatus |= STATUS_OP_BIT; } else if (voice) { ++nick; iStatus |= STATUS_VOICE_BIT; } else if (helper) { ++nick; iStatus |= STATUS_HELPER_BIT; } else iStatus |= STATUS_NORMAL_BIT; fUserCount++; fNamesList->AddItem(new NameItem(nick, iStatus)); } } fNamesList->SortItems(SortNames); if (!IsHidden()) { BString buffer; buffer << fOpsCount; vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_OPS, buffer.String()); buffer = ""; buffer << fUserCount; vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_USERS, buffer.String()); } } break; case M_RESIZE_VIEW: { BPoint point; msg->FindPoint("loc", &point); point.x -= Frame().left; float offset((int32)(point.x - (fNamesScroll->Frame().left))); fResize->MoveBy(offset, 0.0); fTextScroll->ResizeBy(offset, 0.0); fNamesScroll->ResizeBy(-offset, 0.0); fNamesScroll->MoveBy(offset, 0.0); BRect namesRect(0, 0, fNamesScroll->Bounds().Width(), 0); vision_app->SetRect("namesListRect", namesRect); } break; case M_SERVER_DISCONNECT: { // clear names list on disconnect fNamesList->ClearList(); fOpsCount = 0; fUserCount = 0; // clear heuristics completion list - this ensures that no stale nicks are left // over in it after reconnect -- list will quickly be rebuilt anyhow if there // is any conversation whatsoever going on while (fRecentNicks.CountItems() > 0) delete fRecentNicks.RemoveItemAt(0L); } break; case M_REJOIN: { const char* newNick(NULL); if (msg->FindString("nickname", &newNick) != B_OK) { printf("Error: ChannelAgent::MessageReceived, M_REJOIN: invalid pointer\n"); break; } fMyNick = newNick; // update nickname (might have changed on reconnect) if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_NICK, fMyNick.String()); Display(S_CHANNEL_RECON_REJOIN B_UTF8_ELLIPSIS "\n", C_ERROR, C_BACKGROUND, F_SERVER); // send join cmd BMessage send(M_SERVER_SEND); AddSend(&send, "JOIN "); AddSend(&send, fId); if (fChanKey != "") { AddSend(&send, " "); AddSend(&send, fChanKey); } AddSend(&send, endl); } break; case M_CHANNEL_TOPIC: { const char* theTopic(NULL); BString buffer; if (msg->FindString("topic", &theTopic) != B_OK) { printf("ChannelAgent::MessageReceived, M_CHANNEL_TOPIC: invalid pointer\n"); break; } fTopic = theTopic; if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue( STATUS_META, FilterCrap(theTopic, true).String()); BMessage display; if (msg->FindMessage("display", &display) == B_NO_ERROR) ClientAgent::MessageReceived(&display); } break; case M_OPEN_MSGAGENT: { const char* theNick(NULL); msg->FindString("nick", &theNick); if (theNick == NULL) { NameItem* myUser; int32 pos = fNamesList->CurrentSelection(); if (pos >= 0) { myUser = static_cast<NameItem*>(fNamesList->ItemAt(pos)); BString targetNick = myUser->Name(); msg->AddString("nick", targetNick.String()); } } fSMsgr.SendMessage(msg); } break; case M_CHANNEL_GOT_KICKED: { const char* theChannel(NULL), *kicker(NULL), *rest(NULL); if ((msg->FindString("channel", &theChannel) != B_OK) || (msg->FindString("kicker", &kicker) != B_OK) || (msg->FindString("rest", &rest) != B_OK)) { printf("Error: ClientAgent::MessageReceived, M_CHANNEL_GOT_KICKED, invalid pointer\n"); break; } BMessage wegotkicked(M_DISPLAY); // "you were kicked" BString buffer; buffer += S_CHANNEL_GOT_KICKED; buffer += theChannel; buffer += " " S_CHANNEL_GOT_KICKED2 " "; buffer += kicker; buffer += " ("; buffer += rest; buffer += ")\n"; PackDisplay(&wegotkicked, buffer.String(), C_QUIT, C_BACKGROUND, F_TEXT); // clean up fNamesList->ClearList(); fOpsCount = 0; fUserCount = 0; fMsgr.SendMessage(&wegotkicked); BMessage attemptrejoin(M_DISPLAY); // "you were kicked" buffer = S_CHANNEL_REJOIN; buffer += theChannel; buffer += B_UTF8_ELLIPSIS "\n"; PackDisplay(&attemptrejoin, buffer.String(), C_QUIT, C_BACKGROUND, F_TEXT); fMsgr.SendMessage(&attemptrejoin); BMessage send(M_SERVER_SEND); AddSend(&send, "JOIN "); AddSend(&send, theChannel); if (fChanKey != "") { AddSend(&send, " "); AddSend(&send, fChanKey); } AddSend(&send, endl); } break; case M_CHANNEL_MODE: { ModeEvent(msg); } break; case M_CHANNEL_MSG: { bool hasNick(false); BString tempString, theNick, knownAs; msg->FindString("msgz", &tempString); msg->FindString("nick", &theNick); if (theNick != fMyNick) FirstKnownAs(tempString, knownAs, &hasNick); if (IsHidden()) { UpdateStatus((hasNick) ? WIN_NICK_BIT : WIN_NEWS_BIT); if (hasNick) { if (tempString[0] == '\1') { tempString.RemoveFirst("\1ACTION "); tempString.RemoveLast("\1"); } BNotification notification(B_INFORMATION_NOTIFICATION); notification.SetGroup(BString("Vision")); entry_ref ref = vision_app->AppRef(); notification.SetOnClickFile(&ref); notification.SetTitle(fServerName.String()); BString content; content.SetToFormat("%s - %s said: %s", fId.String(), theNick.String(), tempString.String()); notification.SetContent(content); notification.Send(); } } else if (hasNick) system_beep(kSoundEventNames[(uint32)seNickMentioned]); ClientAgent::MessageReceived(msg); } break; case M_CHANNEL_MODES: { const char* mode(NULL), *chan(NULL), *msgz(NULL); if ((msg->FindString("mode", &mode) != B_OK) || (msg->FindString("chan", &chan) != B_OK) || (msg->FindString("msgz", &msgz) != B_OK)) { printf("Error: ChannelAgent::MessageReceived, M_CHANNEL_MODES: invalid pointer\n"); break; } if (fId.ICompare(chan) == 0) { BString realMode(GetWord(mode, 1)); int32 place(2); if (realMode.FindFirst("l") >= 0) fChanLimit = GetWord(mode, place++); if (realMode.FindFirst("k") >= 0) { fChanKey = GetWord(mode, place++); // u2 may not send the channel key, thats why we stored the /join cmd // in a string in ParseCmd if (fChanKey == "*" && fIrcdtype == IRCD_UNDERNET) { BString tempId(fId); tempId.Remove(0, 1); // remove any #, &, !, blah. if (vision_app->pClientWin()->joinStrings.FindFirst(tempId) < 1) { // can't find the join cmd for this channel in joinStrings! } else { BString joinStringsL(vision_app->pClientWin()->joinStrings); // FindLast to make sure we get the last attempt (user might have // tried several keys) int32 idPos(joinStringsL.FindLast(tempId)); BString tempKeyString; joinStringsL.MoveInto(tempKeyString, idPos, joinStringsL.Length()); fChanKey = GetWord(tempKeyString.String(), 2); } } // end u2-kludge stuff } fChanMode = mode; if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_MODES, fChanMode.String()); } BMessage dispMsg(M_DISPLAY); PackDisplay(&dispMsg, msgz, C_OP, C_BACKGROUND, F_TEXT); BMessenger display(this); display.SendMessage(&dispMsg); } break; case M_NAMES_POPUP_MODE: { const char* inaction(NULL); msg->FindString("action", &inaction); int32 count(0), index(0); BString victims, targetNick, action(inaction), modechar, polarity; NameItem* myUser(NULL); /// action /// if (action.FindFirst("voice") >= 0) modechar = "v"; else if (action.FindFirst("op") >= 0) modechar = "o"; else break; /// polarity /// if (action.FindFirst("de") >= 0) polarity += " -"; else polarity += " +"; /// iterate /// while ((i = fNamesList->CurrentSelection(index++)) >= 0) { myUser = static_cast<NameItem*>(fNamesList->ItemAt(i)); targetNick = myUser->Name(); victims += " "; victims += targetNick; count++; } BString command("/mode "); command += fId; command += polarity; for (i = 0; i < count; i++) command += modechar; command += victims; ParseCmd(command.String()); } break; case M_NAMES_POPUP_CTCP: { const char* inaction(NULL); msg->FindString("action", &inaction); int32 index(0); BString victims, targetNick, action(inaction); NameItem* myUser(NULL); action.ToUpper(); /// iterate /// while ((i = fNamesList->CurrentSelection(index++)) >= 0) { myUser = static_cast<NameItem*>(fNamesList->ItemAt(i)); targetNick = myUser->Name(); victims += targetNick; victims += ","; } victims.RemoveLast(","); BString command("/ctcp "); command += victims; command += " "; command += action; ParseCmd(command.String()); } break; case M_NAMES_POPUP_WHOIS: { int32 index(0); BString victims, targetNick; NameItem* myUser(NULL); /// iterate /// while ((i = fNamesList->CurrentSelection(index++)) >= 0) { myUser = static_cast<NameItem*>(fNamesList->ItemAt(i)); targetNick = myUser->Name(); victims += targetNick; victims += ","; } victims.RemoveLast(","); BString command("/whois "); command += victims; ParseCmd(command.String()); } break; case M_NAMES_POPUP_NOTIFY: { int32 index(0); BString victims, targetNick; NameItem* myUser(NULL); /// iterate /// while ((i = fNamesList->CurrentSelection(index++)) >= 0) { myUser = static_cast<NameItem*>(fNamesList->ItemAt(i)); targetNick = myUser->Name(); victims += targetNick; victims += " "; } victims.RemoveLast(","); BString command("/notify "); command += victims; ParseCmd(command.String()); } break; case M_NAMES_POPUP_DCCCHAT: { int32 index(0); BString targetNick; NameItem* myUser(NULL); /// iterate /// while ((i = fNamesList->CurrentSelection(index++)) >= 0) { myUser = static_cast<NameItem*>(fNamesList->ItemAt(i)); targetNick = myUser->Name(); BString command("/dcc chat "); command += targetNick; ParseCmd(command.String()); } } break; case M_NAMES_POPUP_DCCSEND: { int32 index(0); BString targetNick; NameItem* myUser(NULL); /// iterate /// while ((i = fNamesList->CurrentSelection(index++)) >= 0) { myUser = static_cast<NameItem*>(fNamesList->ItemAt(i)); targetNick = myUser->Name(); BString command("/dcc send "); command += targetNick; ParseCmd(command.String()); } } break; case M_NAMES_POPUP_KICK: { int32 index(0); BString targetNick, kickMsg(vision_app->GetCommand(CMD_KICK)); NameItem* myUser(NULL); /// iterate /// while ((i = fNamesList->CurrentSelection(index++)) >= 0) { myUser = static_cast<NameItem*>(fNamesList->ItemAt(i)); targetNick = myUser->Name(); BString command("/kick "); command += targetNick; command += " "; command += kickMsg; ParseCmd(command.String()); } } break; case M_STATUS_ADDITEMS: { vision_app->pClientWin()->pStatusView()->AddItem(new StatusItem(0, ""), true); vision_app->pClientWin()->pStatusView()->AddItem( new StatusItem(S_STATUS_LAG, "", STATUS_ALIGN_LEFT), true); vision_app->pClientWin()->pStatusView()->AddItem(new StatusItem(0, "", STATUS_ALIGN_LEFT), true); vision_app->pClientWin()->pStatusView()->AddItem(new StatusItem(S_STATUS_USERS, ""), true); vision_app->pClientWin()->pStatusView()->AddItem(new StatusItem(S_STATUS_OPS, ""), true); vision_app->pClientWin()->pStatusView()->AddItem(new StatusItem(S_STATUS_MODES, ""), true); vision_app->pClientWin()->pStatusView()->AddItem(new StatusItem("", "", STATUS_ALIGN_LEFT), true); // The false bool for SetItemValue() tells the StatusView not to Invalidate() the view. // We send true on the last SetItemValue(). vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_SERVER, fServerName.String(), false); vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_LAG, fMyLag.String(), false); vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_NICK, fMyNick.String(), false); vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_MODES, fChanMode.String(), false); vision_app->pClientWin()->pStatusView()->SetItemValue( STATUS_META, FilterCrap(fTopic.String(), true).String()); BString buffer; buffer << fUserCount; vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_USERS, buffer.String(), false); buffer = ""; buffer << fOpsCount; vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_OPS, buffer.String(), true); } break; case M_CHANNEL_OPTIONS_SHOW: { if (fChanOpt) fChanOpt->Activate(); else { fChanOpt = new ChannelOptions(fId.String(), this); fChanOpt->Show(); } } break; case M_CHANNEL_OPTIONS_CLOSE: { fChanOpt = NULL; } break; case M_CLIENT_QUIT: { if ((msg->HasBool("vision:part") && msg->FindBool("vision:part")) || (msg->HasBool("vision:winlist") && msg->FindBool("vision:winlist"))) { BMessage send(M_SERVER_SEND); AddSend(&send, "PART "); AddSend(&send, fId); if (msg->HasString("vision:partmsg")) { AddSend(&send, " :"); AddSend(&send, msg->FindString("vision:partmsg")); } AddSend(&send, endl); } ClientAgent::MessageReceived(msg); } break; default: ClientAgent::MessageReceived(msg); } }
void ChannelAgent::ModeEvent(BMessage* msg) { int32 modPos(0), targetPos(1); const char* mode(0), *target(0), *theNick(0); char theOperator(0); bool hit(false); // TODO Change Status to bitmask -- Too hard this way msg->FindString("mode", &mode); msg->FindString("target", &target); msg->FindString("nick", &theNick); BString buffer, targetS(target); buffer += "*** "; buffer += theNick; buffer += S_CHANNEL_SET_MODE; buffer += mode; if (targetS != "-9z99") { buffer += " "; buffer += targetS; } buffer += "\n"; BMessenger display(this); BMessage modeMsg(M_DISPLAY); PackDisplay(&modeMsg, buffer.String(), C_OP, C_BACKGROUND, F_TEXT); display.SendMessage(&modeMsg); // at least one if (mode && *mode && *(mode + 1)) theOperator = mode[modPos++]; while (theOperator && mode[modPos]) { char theModifier(mode[modPos]); if (theModifier == 'o' || theModifier == 'v' || theModifier == 'h') { BString myTarget(GetWord(target, targetPos++)); NameItem* item; int32 pos; if ((pos = FindPosition(myTarget.String())) < 0 || (item = static_cast<NameItem*>(fNamesList->ItemAt(pos))) == 0) { printf("[ERROR] Couldn't find %s in NamesView\n", myTarget.String()); return; } int32 iStatus(item->Status()); if (theOperator == '+' && theModifier == 'o') { hit = true; if ((iStatus & STATUS_OP_BIT) == 0) { item->SetStatus((iStatus & ~STATUS_NORMAL_BIT) | STATUS_OP_BIT); ++fOpsCount; buffer = ""; buffer << fOpsCount; if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_OPS, buffer.String()); } } else if (theModifier == 'o') { hit = true; if ((iStatus & STATUS_OP_BIT) != 0) { iStatus &= ~STATUS_OP_BIT; if ((iStatus & STATUS_VOICE_BIT) == 0) iStatus |= STATUS_NORMAL_BIT; item->SetStatus(iStatus); --fOpsCount; buffer = ""; buffer << fOpsCount; if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_OPS, buffer.String()); } } if (theOperator == '+' && theModifier == 'v') { hit = true; item->SetStatus((iStatus & ~STATUS_NORMAL_BIT) | STATUS_VOICE_BIT); } else if (theModifier == 'v') { hit = true; iStatus &= ~STATUS_VOICE_BIT; if ((iStatus & STATUS_OP_BIT) == 0) iStatus |= STATUS_NORMAL_BIT; item->SetStatus(iStatus); } if (theOperator == '+' && theModifier == 'h') { hit = true; item->SetStatus((iStatus & ~STATUS_NORMAL_BIT) | STATUS_HELPER_BIT); } else if (theModifier == 'h') { hit = true; iStatus &= ~STATUS_HELPER_BIT; if ((iStatus & STATUS_HELPER_BIT) == 0) iStatus |= STATUS_NORMAL_BIT; item->SetStatus(iStatus); } } else if (theModifier == 'l' && theOperator == '-') { BString myTarget(GetWord(target, targetPos++)); UpdateMode('-', 'l'); fChanLimit = ""; } else if (theModifier == 'l') { BString myTarget(GetWord(target, targetPos++)); fChanLimitOld = fChanLimit; fChanLimit = myTarget; UpdateMode('+', 'l'); } else if (theModifier == 'k' && theOperator == '-') { UpdateMode('-', 'k'); fChanKey = ""; } else if (theModifier == 'k') { BString myTarget(GetWord(target, targetPos++)); fChanKeyOld = fChanKey; fChanKey = myTarget; UpdateMode('+', 'k'); } else if (theModifier == 'b' || theModifier == 'a' || theModifier == 'q') { // dont do anything else } else { UpdateMode(theOperator, theModifier); } ++modPos; if (mode[modPos] == '+' || mode[modPos] == '-') theOperator = mode[modPos++]; } if (hit) { fNamesList->SortItems(SortNames); fNamesList->Invalidate(); } }
void check(ElementType Key, HashTable H) { Position Pos = FindPosition(Key,H); if (Pos) printf("%-6d found!\n",Key); else printf("%-6d not found!\n",Key); }
void Delete( ElementType Key, HashTable H ) { Position Pos; Pos = FindPosition( Key, H ); H->TheCells[ Pos ].Info = Deleted; }
// ********************************************************** // get_UndoCount // ********************************************************** STDMETHODIMP CUndoList::get_UndoCount(LONG* pVal) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); *pVal = CheckState() ? FindPosition(_position) : -1; return S_OK; }
LPBNDS BuildBounds ( WORD coff, LPUL rgoff, LPW lpcbnds ) { LPBNDS rgbnds = (LPBNDS) MHAlloc (sizeof (BNDS) * cbndsAllocBlock); WORD cbndsAlloc = cbndsAllocBlock; WORD cbnds = 0; WORD ioff = 0; while (ioff < coff) { ULONG uoffCurr = rgoff [ ioff ]; ULONG uoffMax = 0; WORD ibnds = FindPosition (rgbnds, cbnds, rgoff, uoffCurr); if (ibnds == cbnds) { // We're after all other known blocks, so our max // is "infinity" uoffMax = 0xFFFFFFFF; rgbnds = InsertBlock (ibnds, 1, rgbnds, &cbnds, &cbndsAlloc); } else if (rgoff [ rgbnds [ ibnds ].ilnStart ] > uoffCurr) { // We're at an insertion point, not in the middle of // another block candidate uoffMax = rgoff [ rgbnds [ ibnds ].ilnStart ]; rgbnds = InsertBlock (ibnds, 1, rgbnds, &cbnds, &cbndsAlloc); } else { // We're in the middle of another block candidate, so we // must split it in two rgbnds = InsertBlock (ibnds, 2, rgbnds, &cbnds, &cbndsAlloc); // Start of ibnds is already set rgbnds [ ibnds ].ilnEnd = ScanBlock ( rgoff, coff, rgbnds [ ibnds ].ilnStart, uoffCurr ); rgbnds [ ibnds + 2 ].ilnStart = rgbnds [ ibnds ].ilnEnd + 1; // End of ibnds + 2 is already set uoffMax = rgoff [ rgbnds [ ibnds + 2 ].ilnStart ]; ibnds += 1; } rgbnds [ ibnds ].ilnStart = ioff; rgbnds [ ibnds ].ilnEnd = ScanBlock (rgoff, coff, ioff, uoffMax); ioff = rgbnds [ ibnds ].ilnEnd + 1; } *lpcbnds = cbnds; return rgbnds; }