本文整理汇总了C++中CArray::InsertAt方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::InsertAt方法的具体用法?C++ CArray::InsertAt怎么用?C++ CArray::InsertAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::InsertAt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindRelevantNode
Skein::Node* TranscriptWindow::FindRelevantNode(FindAction action, bool next, bool selected)
{
// Get all the nodes in the transcript or skein
CArray<Skein::Node*,Skein::Node*> nodes;
if (action == SkeinDifferent)
{
ASSERT(next);
m_skein->GetAllNodes(nodes);
}
else
{
Skein::Node* node = m_skeinEndThread;
while (node != NULL)
{
if (next)
nodes.InsertAt(0,node);
else
nodes.Add(node);
node = node->GetParent();
}
}
if (next)
nodes.InsertAt(0,(Skein::Node*)NULL);
// Return the next relevant node after the selected node (which may be NULL)
bool afterSelected = false;
for (int i = 0; i < nodes.GetSize(); i++)
{
if (afterSelected == false)
{
if (nodes.GetAt(i) == (selected ? m_skeinSelected : NULL))
afterSelected = true;
}
else
{
switch (action)
{
case TranscriptDifferent:
case SkeinDifferent:
if (nodes.GetAt(i)->GetDiffers() != Skein::Node::ExpectedSame)
return nodes.GetAt(i);
break;
case TranscriptChanged:
if (nodes.GetAt(i)->GetChanged())
return nodes.GetAt(i);
break;
default:
ASSERT(FALSE);
break;
}
}
}
// If nothing found, then if searching the whole skein, start from the beginning
if ((action == SkeinDifferent) && selected)
return FindRelevantNode(action,next,false);
return NULL;
}
示例2: DelSelItems
void CFileSelectList::DelSelItems()
{
POSITION pos = GetFirstSelectedItemPosition();
CArray<int> aryIndex;
while(pos != NULL)
{
aryIndex.InsertAt(0,GetNextSelectedItem(pos));
}
for(int i= 0;i<aryIndex.GetCount();++i)
{
ItemDataType* pItemData = (ItemDataType*)GetItemData(aryIndex[i]);
SAFE_DELETE(pItemData)
DeleteItem(aryIndex[i]);
}
}
示例3: main
void main()
{
CArray arr;
arr.Add(1234);
arr.Add(23);
arr.Add(44);
arr.Add(21);
arr.Add(5);
arr.RemoveAt(2,20000000); //从第二个位置起,删除2个数据
arr.InsertAt(3,10,2);
int i = 0;
int nSize = arr.GetSize();
cout << "共有 " << nSize << " 条数据" << endl;
TYPE *p = arr.GetData();
qsort(p,nSize,sizeof(TYPE),compar);
while(i < nSize)
{
cout << arr[i] << endl;
++i;
}
}
示例4: InsertColumn
void CItemData::InsertColumn(int nColumn)
{
aTextColors.InsertAt(nColumn, ::GetSysColor(COLOR_WINDOWTEXT));
aBkColors.InsertAt(nColumn, ::GetSysColor(COLOR_WINDOW));
}
示例5: SubstituteTags
int CProxy::SubstituteTags(CString *buf, int skAccept, int searchflag, char *searchstring, int startswithflag, char *startswithstring, char *errorcode, int adminFlag)
{
int ret = 0;
int iError = 0;
char *pszSongTitle = (char *)1;
char szArtist[255] = "";
int playlistpos = 0;
CString substituted;
char tmpbuf[1024] = "";
int replaceflag = 0;
CString tempArtist;
int foundit = 0;
int loop = 1;
int errorCode = 0;
errorCode = atoi(errorcode);
ret = buf->Find("%%ARTISTSELECT%%");
if (ret != -1) {
while(loop) {
memset(szArtist, '\000', sizeof(szArtist));
loop = getArtist(playlistpos, szArtist);
if(loop) {
tempArtist = szArtist;
foundit = 0;
for(int i=0;i <= ArtistList.GetUpperBound();i++) {
if (ArtistList.GetAt(i) == tempArtist) {
foundit = 1;
}
}
if (!foundit) {
if (strlen(tempArtist) > 0) {
ArtistList.Add(tempArtist);
}
}
}
playlistpos++;
}
CArray<CString, CString &> ArtistListSorted;
for(int j=0;j <= ArtistList.GetUpperBound();j++) {
int added = 0;
for (int k=0;k <= ArtistListSorted.GetUpperBound();k++) {
if (ArtistList.GetAt(j) < ArtistListSorted.GetAt(k)) {
ArtistListSorted.InsertAt(k, ArtistList.GetAt(j));
added = 1;
break;
}
}
if (!added) {
ArtistListSorted.Add(ArtistList.GetAt(j));
}
}
for(int i=0;i <= ArtistListSorted.GetUpperBound();i++) {
substituted = *buf;
substituted.Replace("%%ARTISTSELECT%%", ArtistListSorted.GetAt(i));
iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0);
iError = send(skAccept, "\r\n", strlen("\r\n"), 0);
}
return 1;
}
ret = buf->Find("%%ADMINWINAMPCONTROL%%");
if (ret != -1) {
substituted = *buf;
if (adminFlag) {
char hiddenfield[1024] = "";
sprintf(hiddenfield, "<table bordercolor=white border=1><tr><td colspan=5>Winamp Admin Control</td></tr><tr><td><a href=\"admin.cgi?pass=%s&action=prev\">Prev</td><td><a href=\"admin.cgi?pass=%s&action=play\">Play</td><td><a href=\"admin.cgi?pass=%s&action=pause\">Pause</td><td><a href=\"admin.cgi?pass=%s&action=stop\">Stop</td><td><a href=\"admin.cgi?pass=%s&action=next\">Next</td><tr><td colspan=5><a href=\"admin.cgi?pass=%s&action=refreshcache\">Refresh Playlist Cache</td></tr></table>", g_AdminPassword, g_AdminPassword, g_AdminPassword, g_AdminPassword, g_AdminPassword, g_AdminPassword);
substituted.Replace("%%ADMINWINAMPCONTROL%%", hiddenfield);
}
else {
substituted.Replace("%%ADMINWINAMPCONTROL%%", "");
}
iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0);
iError = send(skAccept, "\r\n", strlen("\r\n"), 0);
return 1;
}
ret = buf->Find("%%ADMINHIDDENFIELD%%");
if (ret != -1) {
substituted = *buf;
if (adminFlag) {
char hiddenfield[1024] = "";
sprintf(hiddenfield, "<input type=hidden name=pass value=\"%s\">", g_AdminPassword);
substituted.Replace("%%ADMINHIDDENFIELD%%", hiddenfield);
}
else {
substituted.Replace("%%ADMINHIDDENFIELD%%", "");
}
iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0);
iError = send(skAccept, "\r\n", strlen("\r\n"), 0);
return 1;
}
ret = buf->Find("%%ADMINPASSWORD%%");
//.........这里部分代码省略.........
示例6: RequestHandler
void CProxy::RequestHandler(char *request)
{
int playlistpos = 0;
char suppliedPass[255] = "";
char variable[255] = "";
char value[255] = "";
int action = 0;
int adminFlag = 0;
char msg[255] = "";
int valid = 0;
int errorCode = 0;
int requestFlag = 0;
if (!strncmp(request, "/request.cgi", strlen("/request.cgi"))) {
char *p1;
p1 = strchr(request, '?');
if (p1) {
p1++;
char *token;
token = strtok(p1, "&");
while (token != NULL) {
char *p2;
p2 = strchr(token, '=');
if (p2) {
memset(variable, '\000', sizeof(variable));
memset(value, '\000', sizeof(value));
int lengthtocopy = 0;
if ((p2-token) > (sizeof(variable)-1)) {
lengthtocopy = sizeof(variable)-1;
}
else {
lengthtocopy = p2-token;
}
strncpy(variable, token, lengthtocopy);
p2++;
strncpy(value, p2, sizeof(value)-1);
if (!strcmp(variable, "pass")) {
strncpy(suppliedPass, value, sizeof(suppliedPass)-1);
}
if (!strcmp(variable, "listpos")) {
playlistpos = atoi(value);
}
}
token = strtok(NULL, "&");
}
}
if (strlen(g_AdminPassword) > 0) {
if (!strcmp(suppliedPass, g_AdminPassword)) {
adminFlag = 1;
}
else {
adminFlag = 0;
}
}
requestFlag = 1;
}
// if (sscanf(request, "/request.cgi?listpos=%d", &playlistpos) == 1) {
if (requestFlag) {
if (adminFlag) {
errorCode = REQUEST_ACCEPTED;
}
else {
errorCode = ValidateRequest(playlistpos);
}
if (errorCode == REQUEST_ACCEPTED) {
EnterCriticalSection(&GlobalCriticalSection_QueueList);
Req_Queue newQueueItem;
newQueueItem.playlistpos = playlistpos;
newQueueItem.requestingIP = connectedTo;
RequestQueue.InsertAt(0, newQueueItem, 1);
LeaveCriticalSection(&GlobalCriticalSection_QueueList);
}
}
char location[1024] = "";
if (strlen(m_Referrer) > 0) {
CString tS = m_Referrer;
tS.Replace("action=", "actionx=");
strcpy(m_Referrer, LPCSTR(tS));
if (errorCode == 0) {
_snprintf(location, sizeof(location)-1, "Location: %s", m_Referrer);
}
else {
_snprintf(location, sizeof(location)-1, "Location: %s&errorCode=%d", m_Referrer, errorCode);
}
}
else {
if (errorCode == 0) {
_snprintf(location, sizeof(location)-1, "Location: /playlist.cgi");
}
else {
_snprintf(location, sizeof(location)-1, "Location: /playlist.cgi?errorCode=%d", errorCode);
}
}
//.........这里部分代码省略.........
示例7: CreateNewVertexList
SSHANDLE* CSSolid::CreateNewVertexList(CSSFace *pFace, CSSEdge *pEdge1,
CSSEdge *pEdge2, int& nv1index, int& nv2index,
CSSVertex *pNewVertex1, CSSVertex *pNewVertex2)
{
// get original vertex list
CArray<SSHANDLE, SSHANDLE&> hVertexList;
hVertexList.SetSize(pFace->nEdges+4);
CreatePointHandleList(*pFace, hVertexList.GetData());
// add vertex1 and vertex2.
nv1index = -1;
nv2index = -1;
int nVertices = pFace->nEdges;
int iPass = 0;
DoAgain:
for(int i = 0; i < nVertices; i++)
{
int iPrevIndex = GetNext(i, -1, nVertices);
int iNextIndex = GetNext(i, 1, nVertices);
if(nv1index == -1 && (hVertexList[i] == pEdge1->hvEnd ||
hVertexList[i] == pEdge1->hvStart))
{
// find pEdge1->hvStart
if(hVertexList[iPrevIndex] == pEdge1->hvStart ||
hVertexList[iPrevIndex] == pEdge1->hvEnd)
{
// add at i.
nv1index = i;
}
if(hVertexList[iNextIndex] == pEdge1->hvStart ||
hVertexList[iNextIndex] == pEdge1->hvEnd)
{
// add at iNextIndex
nv1index = iNextIndex;
}
if(nv1index != -1)
{
hVertexList.InsertAt(nv1index, pNewVertex1->id);
++nVertices;
break;
}
}
if(nv2index == -1 && (hVertexList[i] == pEdge2->hvEnd ||
hVertexList[i] == pEdge2->hvStart))
{
// find pEdge1->hvStart
if(hVertexList[iPrevIndex] == pEdge2->hvStart ||
hVertexList[iPrevIndex] == pEdge2->hvEnd)
{
// add at i.
nv2index = i;
}
if(hVertexList[iNextIndex] == pEdge2->hvStart ||
hVertexList[iNextIndex] == pEdge2->hvEnd)
{
// add at iNextIndex
nv2index = iNextIndex;
}
if(nv2index != -1)
{
hVertexList.InsertAt(nv2index, pNewVertex2->id);
++nVertices;
break;
}
}
}
SSHANDLE hTmp[64];
memcpy(hTmp, hVertexList.GetData(), sizeof(SSHANDLE) * nVertices);
if(nv1index == -1 && nv2index == -1)
return NULL; // not used here.
if(nv1index == -1 || nv2index == -1)
{
if(++iPass != 2)
goto DoAgain;
}
SSHANDLE *rvl = new SSHANDLE[nVertices];
memcpy(rvl, hVertexList.GetData(), sizeof(SSHANDLE) * nVertices);
return rvl;
}
示例8: AddIndicator
BOOL MPCStatusBar::AddIndicator( int position, UINT paneID )
{
CArray<MPCStatusBarPane,MPCStatusBarPane> arPanes;
MPCStatusBarPane statusPane;
int i;
i = 0;
while( GetStatusPane(i,statusPane) )
{
arPanes.Add( statusPane );
i++;
}
if( position < 0 )
position = 0;
if( position > arPanes.GetSize() )
position = arPanes.GetSize()-1;
for(i = 0; i < arPanes.GetSize(); i ++ )
{
if( paneID == arPanes[i].nID )
{
TRACE(_T("XFXStatusBar::AddIndicator(): Pane ID already exists \n"));
return FALSE;
}
}
MPCStatusBarPane new_statusPane;
new_statusPane.nID = paneID;
if( arPanes.GetSize() )
arPanes.InsertAt(position,new_statusPane);
else
arPanes.Add(new_statusPane);
UINT * pIndicators = new UINT[arPanes.GetSize()];
for(i=0;i<arPanes.GetSize();i++)
pIndicators[i]=arPanes[i].nID;
SetRedraw(FALSE);
SetIndicators(pIndicators,arPanes.GetSize());
// Replace infos of indicators ..
for(i = 0; i < arPanes.GetSize(); i++ )
{
if( arPanes[i].nID != paneID )
{
SetPaneInfo(i,arPanes[i].nID,arPanes[i].nStyle,arPanes[i].cxText);
SetPaneText(i,arPanes[i].strText);
}
else
{
SetPaneWidth(i,50);
SetPaneText(i,arPanes[i].strText);
}
}
delete pIndicators;
SetRedraw(TRUE);
PositionControls();
Invalidate(TRUE);
return TRUE;
}