本文整理汇总了C++中ListInsert函数的典型用法代码示例。如果您正苦于以下问题:C++ ListInsert函数的具体用法?C++ ListInsert怎么用?C++ ListInsert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ListInsert函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
/// create list
SqList List;
InitList(&List);
/// insert element to list
ListInsert(&List, 1, 1);
ListInsert(&List, 2, 2);
ListInsert(&List, 3, 3);
ListInsert(&List, 4, 4);
ListInsert(&List, 5, 5);
/// locate element
printf("element %d is in %d\n", 4, LocateElem(&List, 4));
/// list length
int length = ListLength(&List);
printf("List length is %d\n", length);
/// get list element
int i, element;
for (i = 1; i <= length; i++) {
GetElem(&List, i, &element);
printf("element in %d is %d\n", i, element);
}
/// delect element from list
ListDelete(&List, 4, &element);
printf("deleted element in %d is %d\n", 4, element);
/// clear list
ClearList(&List);
printf("List empty is %d\n", ListEmpty(&List));
return EXIT_SUCCESS;
}
开发者ID:chenxilinsidney,项目名称:funnycprogram,代码行数:30,代码来源:test_sequence_list.c
示例2: MergeList
void MergeList(SqList La,SqList Lb,SqList &Lc) // 算法2.2
{ // 已知线性表La和Lb中的数据元素按值非递减排列。
// 归并La和Lb得到新的线性表Lc,Lc的数据元素也按值非递减排列
int i=1,j=1,k=0;
int La_len,Lb_len;
ElemType ai,bj;
InitList(Lc); // 创建空表Lc
La_len=ListLength(La);
Lb_len=ListLength(Lb);
while(i<=La_len&&j<=Lb_len) // 表La和表Lb均非空
{
GetElem(La,i,ai);
GetElem(Lb,j,bj);
if(ai<=bj)
{
ListInsert(Lc,++k,ai);
++i;
}
else
{
ListInsert(Lc,++k,bj);
++j;
}
} // 以下两个while循环只会有一个被执行
while(i<=La_len) // 表La非空且表Lb空
{
GetElem(La,i++,ai);
ListInsert(Lc,++k,ai);
}
while(j<=Lb_len) // 表Lb非空且表La空
{
GetElem(Lb,j++,bj);
ListInsert(Lc,++k,bj);
}
}
开发者ID:jiayuehua,项目名称:datastructure_gao,代码行数:35,代码来源:Algo2-2.cpp
示例3: main
int main()
{
DPoint _PFir;
DPoint _PSec;
DPoint _PAim;
DPoint _pCro;
_PFir._PointX=0.0;
_PFir._PointY=0.0;
_PSec._PointX=100.0;
_PSec._PointY=0.0;
_PAim._PointX=20.0;
_PAim._PointY=60.0;
CalcuVertical(_PFir,_PSec, _PAim,&_pCro);
printf("%.6lf, %.6lf", _pCro._PointX, _pCro._PointY);
printf("%.6lf",CalcuDis(_PFir,_PSec,_PAim));
////////////////////////////////////////
SqList lo;
ListInit(&lo);
DPoint _dPValue;
DPoint _dPIValue;
_dPValue._PointX = 100.0;
_dPValue._PointY = 100.0;
_dPIValue._PointX = 300.0;
_dPIValue._PointY = 300.0;
for (size_t _i=0;_i<3;_i++)
{
ListInsert(&lo,1,_dPValue);
}
ListInsert(&lo,2,_dPIValue);
printf("%.6lf,%.6lf",lo._nArray[0]._PointX,lo._nArray[0]._PointX);
//////////////////////////////////////
// vector<vector<CPoint>> _vecPOINT;
// vector<CPoint> _vecIn;
// CPoint _ptFir;
// CPoint _ptIn;
// _ptIn.SetPoint(300,300);
// _ptFir.SetPoint(100,100);
//
// _vecIn.push_back(_ptFir);
// for (size_t _i=0; _i<5;_i++)
// {
// _vecIn.push_back(_ptFir);
//_vecPOINT.push_back(_vecIn);
// }
//
// _vecPOINT.push_back(_vecIn);
//
// _vecPOINT[0].insert(_vecPOINT[0].begin()+1,_ptIn);
///////////////////////////////////////
return 0;
}
开发者ID:dusong7,项目名称:C-CPP-Advance-Test,代码行数:59,代码来源:垂直.c
示例4: MergeList1
//Merge1
void MergeList1(SLinkList L)
{
int n=10;
int i=0;
ElemType e;
int j=0;
InitList(L);
printf("请输入A中数据的个数:");
scanf("%d",&i);
if(i>0)
n=i;
for(i=0;i<n;i++)
{
loop:
scanf("%d",&e);
if(!LocateElem(L,e,compare))
ListInsert(L,i+1,e);
else
{
printf("已存在,请重新输入:");
goto loop;
}
}
printf("遍历链表");
TraverseList(L,visit);
printf("\n");
printf("请输入B中数据的个数:");
scanf("%d",&i);
if(i>0)
n=i;
for(i=0;i<n;i++)
{
scanf("%d",&e);
if(!(j=LocateElem(L,e,compare)))
{
ListInsert(L,ListLength(L)+1,e);
}
else
{
ListDelete(L,j,e);
}
}
printf("遍历链表");
TraverseList(L,visit);
printf("\n");
}
开发者ID:shaojunhan,项目名称:MyCode,代码行数:53,代码来源:C_StaticLinkList_Test.cpp
示例5: main
int main(int argc, char *argv[])
{
char initial[10001] = {0};
int n, i;
char ch;
List L;
#ifdef _OJ_
const int SZ = 1<<20;
char inbuf[SZ];
char outbuf[SZ];
setvbuf(stdin,inbuf,_IOFBF,SZ);
setvbuf(stdout,outbuf,_IOFBF,SZ);
#endif
scanf("%s", initial);
InitList(&L, initial);
scanf("%d", &n);
while( n-- )
{
scanf("%d %c", &i, &ch);
ListInsert(L, i, ch);
ListTraverse(L);
}
return 0;
}
开发者ID:durians,项目名称:durians,代码行数:29,代码来源:MOOC-PA1-Zuma.c
示例6: main
int main()
{
struct SqList L;
InitList(&L);
printf("ListEmpty(L) = %d\n", ListEmpty(L));
printSqList(L);
int e;
int index = 7;
GetElem(L, index, &e);
printf("the %d th number is e : %d\n", index, e);
printf("Find %d at index %d\n", e, Locate(L, e));
int insertNum = 100;
ListInsert(&L, index, 100);
printf("Insert %d at index %d into SqList\n", insertNum, index);
printSqList(L);
ListDelete(&L, index, &e);
printf("Delete %d at index %d from SqlList\n", e, index);
printSqList(L);
printf("ListLength(L) = %d\n", ListLength(L));
ClearList(&L);
printf("ListEmpty(L) = %d\n", ListEmpty(L));
printSqList(L);
return 0;
}
开发者ID:Sword2G,项目名称:DataStructures-Algorithm,代码行数:31,代码来源:Sqlist.cpp
示例7: NewWatchedFile
static WatchedFile* NewWatchedFile(const WCHAR* filePath, const std::function<void()>& onFileChangedCb) {
bool isManualCheck = PathIsNetworkPath(filePath);
AutoFreeW dirPath(path::GetDir(filePath));
WatchedDir* wd = nullptr;
bool newDir = false;
if (!isManualCheck) {
wd = FindExistingWatchedDir(dirPath);
if (!wd) {
wd = NewWatchedDir(dirPath);
if (!wd)
return nullptr;
newDir = true;
}
}
WatchedFile* wf = AllocStruct<WatchedFile>();
wf->filePath = str::Dup(filePath);
wf->onFileChangedCb = onFileChangedCb;
wf->watchedDir = wd;
wf->isManualCheck = isManualCheck;
ListInsert(&g_watchedFiles, wf);
if (wf->isManualCheck) {
GetFileState(filePath, &wf->fileState);
AwakeWatcherThread();
} else {
if (newDir)
StartMonitoringDirForChanges(wf->watchedDir);
}
return wf;
}
开发者ID:sambhare,项目名称:sumatrapdf,代码行数:33,代码来源:FileWatcher.cpp
示例8: MediaSrvRegistCallback
////////////////////////////////////////////////////
// 功能:
// 输入:
// 输出:
// 返回:
// 说明:
////////////////////////////////////////////////////
int MediaSrvRegistCallback(int type, DWORD device, PMEDIA_CALLBACK callback)
{
PLIST n;
PLIST head;
PCALLBACK_LINK check;
PCALLBACK_LINK link;
// 申请节点,并初始化
link = kmalloc(sizeof(CALLBACK_LINK));
if(link == NULL)
return -1;
kmemcpy(&link->Callback, callback, sizeof(MEDIA_CALLBACK));
link->Type = type;
link->Device = device;
ListInit(&link->Link);
// 检查设备是否已经注册
head = &MediaCallbackList;
for(n=ListFirst(head); n!=head; n=ListNext(n))
{
check = ListEntry(n, CALLBACK_LINK, Link);
if(&check->Callback == callback)
{
kfree(link);
return -1;
}
}
ListInsert(&MediaCallbackList, &link->Link);
return 0;
}
开发者ID:DanielGit,项目名称:Intrisit201202,代码行数:37,代码来源:MediaSrv.c
示例9: main
int main()
{
int i = 0;
char Sq_list[MAX] = "abcdefg";
char data;
printf("The content of the list\n");
for(i = 0;(i < MAX && Sq_list[i] != 0); i++)
{
printf("%c\t",Sq_list[i]);
if((i+1)%8 == 0)
printf("\n");
}
printf("\n");
unsigned int position = 0;
printf("Put in the position you wanner to insert!\n");
scanf("%d,",&position);
printf("Put in the data you wanner insert\n");
scanf("%c",&data);
ListInsert(Sq_list,position,data);
printf("The insert result:\n");
for(i = 0;(i < MAX && Sq_list[i] != 0); i++)
{
printf("%c\t",Sq_list[i]);
if((i+1)%8 == 0)
printf("\n");
}
}
开发者ID:YouYaoGuai,项目名称:Problem1,代码行数:27,代码来源:ListInsert.c
示例10: PathIsNetworkPath
static WatchedFile *NewWatchedFile(const WCHAR *filePath, FileChangeObserver *observer)
{
bool isManualCheck = PathIsNetworkPath(filePath);
ScopedMem<WCHAR> dirPath(path::GetDir(filePath));
WatchedDir *wd = nullptr;
bool newDir = false;
if (!isManualCheck) {
wd = FindExistingWatchedDir(dirPath);
if (!wd) {
wd = NewWatchedDir(dirPath);
if (!wd)
return nullptr;
newDir = true;
}
}
WatchedFile *wf = AllocStruct<WatchedFile>();
wf->filePath = str::Dup(filePath);
wf->observer = observer;
wf->watchedDir = wd;
wf->isManualCheck = isManualCheck;
ListInsert(&g_watchedFiles, wf);
if (wf->isManualCheck) {
GetFileState(filePath, &wf->fileState);
AwakeWatcherThread();
} else {
if (newDir)
StartMonitoringDirForChanges(wf->watchedDir);
}
return wf;
}
开发者ID:AnthonyLu-Ista,项目名称:sumatrapdf,代码行数:34,代码来源:FileWatcher.cpp
示例11: RegisterLayoutCreatorFor
void RegisterLayoutCreatorFor(const char *layoutName, LayoutCreatorFunc creator)
{
LayoutCreatorNode *lc = AllocStruct<LayoutCreatorNode>();
lc->typeName = str::Dup(layoutName);
lc->creator = creator;
ListInsert(&gLayoutCreators, lc);
}
开发者ID:Nargesf,项目名称:Sumatrapdf,代码行数:7,代码来源:MuiFromText.cpp
示例12: test_Increment
void test_Increment(void) {
LIST_TYPE list = NULL;
Status result = InitialList(&list);
int size = LIST_INITIAL_SIZE + LIST_INCREMENT;
CU_ASSERT_EQUAL(result, OK);
if (result != OK)
return;
int i = 0;
for (i = 0; i < size - 1; i++) {
result = ListInsert(list, 1, i);
CU_ASSERT_EQUAL(result, OK);
if (result != OK)
return;
}
CU_ASSERT_EQUAL(list -> listsize, size);
CU_ASSERT_EQUAL(list -> length, size - 1);
for (i = 0; i < size - 1; i++) {
CU_ASSERT_EQUAL(*(list -> element + i), size
- i - 2);
}
}
开发者ID:yuandong1222,项目名称:DataStructureInC,代码行数:25,代码来源:sequence_list_test.c
示例13: main
int main(void)
{
ElemType site[11] = { 'a', 'n', 'o', 't', 'h', 'e', 'r', 'h', 'o', 'm', 'e' };
LinkList *Link, *LinkR;
ElemType e;
CreateListF(Link, site, 11);
CreateListR(LinkR, site, 11);
DispList(Link);
DispList(LinkR);
DestroyList(LinkR);
if (ListEmpty(Link))
{
printf("List is empty\n");
}
else
{
printf("List isn't empty\n");
}
printf("ListLength: %d\n", ListLength(Link));
GetElem(Link, ListLength(Link), e);
ListInsert(Link, 2, e);
DispList(Link);
ListDelete(Link, 3, e);
DispList(Link);
printf("The location of 'o' is %d\n", LocateElem(Link, 'o'));
DestroyList(Link);
return 0;
}
开发者ID:DIYgod,项目名称:StudyRecord,代码行数:30,代码来源:main.cpp
示例14: main
void main()
{
SqList La,Lb,Lc;
int j,a[4]={3,5,8,11},b[7]={2,6,8,9,11,15,20};
InitList(La); // 创建空表La
for(j=1;j<=4;j++) // 在表La中插入4个元素
ListInsert(La,j,a[j-1]);
printf("La= "); // 输出表La的内容
ListTraverse(La,print1);
InitList(Lb); // 创建空表Lb
for(j=1;j<=7;j++) // 在表Lb中插入7个元素
ListInsert(Lb,j,b[j-1]);
printf("Lb= "); // 输出表Lb的内容
ListTraverse(Lb,print1);
MergeList(La,Lb,Lc);
printf("Lc= "); // 输出表Lc的内容
ListTraverse(Lc,print1);
}
开发者ID:jiayuehua,项目名称:datastructure_gao,代码行数:18,代码来源:Algo2-2.cpp
示例15: ListInsert
void CLuaCallInHandler::AddHandle(CLuaHandle* lh)
{
ListInsert(handles, lh);
#define ADDHANDLE(name) \
if (lh->HasCallIn(#name)) { ListInsert(list ## name, lh); }
ADDHANDLE(GamePreload);
ADDHANDLE(GameStart);
ADDHANDLE(GameOver);
ADDHANDLE(TeamDied);
ADDHANDLE(UnitCreated);
ADDHANDLE(UnitFinished);
ADDHANDLE(UnitFromFactory);
ADDHANDLE(UnitDestroyed);
ADDHANDLE(UnitTaken);
ADDHANDLE(UnitGiven);
ADDHANDLE(UnitIdle);
ADDHANDLE(UnitCmdDone);
ADDHANDLE(UnitDamaged);
ADDHANDLE(UnitExperience);
ADDHANDLE(UnitSeismicPing);
ADDHANDLE(UnitEnteredRadar);
ADDHANDLE(UnitEnteredLos);
ADDHANDLE(UnitLeftRadar);
ADDHANDLE(UnitLeftLos);
ADDHANDLE(UnitLoaded);
ADDHANDLE(UnitUnloaded);
ADDHANDLE(UnitCloaked);
ADDHANDLE(UnitDecloaked);
ADDHANDLE(FeatureCreated);
ADDHANDLE(FeatureDestroyed);
ADDHANDLE(Explosion);
ADDHANDLE(StockpileChanged);
ADDHANDLE(Update);
ADDHANDLE(DefaultCommand);
ADDHANDLE(DrawGenesis);
ADDHANDLE(DrawWorld);
ADDHANDLE(DrawWorldPreUnit);
ADDHANDLE(DrawWorldShadow);
ADDHANDLE(DrawWorldReflection);
ADDHANDLE(DrawWorldRefraction);
ADDHANDLE(DrawScreenEffects);
ADDHANDLE(DrawScreen);
ADDHANDLE(DrawInMiniMap);
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:57,代码来源:LuaCallInHandler.cpp
示例16: main
void main()
{
SqList La, Lb;
int j;
InitList(La);
for ( j = 1; j <= 5; j++ )
ListInsert(La, j, j);
printf("La = ");
ListTraverse(La, print1);
InitList(Lb);
for ( j = 1; j <= 5; j++ )
ListInsert(Lb, j, 2 * j);
printf("Lb = ");
ListTraverse(Lb, print1);
Union(La, Lb);
printf("new La= ");
ListTraverse(La, print1);
}
开发者ID:kobemiller,项目名称:DataStructure,代码行数:18,代码来源:algo2-1.cpp
示例17: main
int main()
{
List list;
InitList(&list);
printf("创建线性表后线性表的当前长度:%d\n", list.length);
printf("ListTraverse:");
//initialize
int j;
for(j = 0; j < 10; j++) {
list.elem[j] = j;
list.length++;
}
printf("after sqlist inited: %d=====%d\n", list.listsize, list.length);
//test DestoryList
/*DestoryList(&list);
printf("After Destory List %d=====%d\n", list.listsize, list.length);*/
//test ListEmpty(List *list);
printf("Is List Empty? %s\n", ListEmpty(&list) ? "true" : "false");
//test GetElem(List *list, int i, ElemType *e)
ElemType e1;
if(GetElem(&list, 3, &e1) ) {
printf("Get index 3 element from list: %d\n", e1);
}
/*for(j = 0; j < list.length; j++) {
if(list.elem[j] == 3)
printf("i found %d in list index %d\n", 3, j);
}*/
//test LocateElem
ElemType e2 = 3;
int position = LocateElem(&list, &e2);
printf("%d\n", position);
if (position >= 0)
printf("I find e2 in list, it's index is %d\n", position);
else
printf("Not Found!\n");
//test ListInsert(List *list, int i, ElemType *e);
ElemType e3 = 100;
if(ListInsert(&list, 2, &e3)) {
ListTraverse(&list);
}
//test BOOL ListDelete
ElemType e4;
if(ListDelete(&list, 2, &e4)) {
printf("Delete index %d ElemType %d success\n", 1, e4);
}
ListTraverse(&list);
return 0;
}
开发者ID:joizhang,项目名称:study,代码行数:57,代码来源:sqlist.c
示例18: main
void main()
{
SqList La, Lb, Lc;
int j;
InitList(&La); /* 创建空表La */
for (j = 1; j <= 5; j++) /* 在表La中插入5个元素 */
ListInsert(&La, j, j);
printf("La= "); /* 输出表La的内容 */
ListTraverse(La, print);
InitList(&Lb); /* 创建空表Lb */
for (j = 1; j <= 5; j++) /* 在表Lb中插入5个元素 */
ListInsert(&Lb, j, 2 * j);
printf("Lb= "); /* 输出表Lb的内容 */
ListTraverse(Lb, print);
MergeList(La, Lb, &Lc);
printf("Lc= "); /* 输出表Lc的内容 */
ListTraverse(Lc, print);
}
开发者ID:xiaomingmai,项目名称:datastructure_yanweimin,代码行数:18,代码来源:ALGO2-3.c
示例19: MQTTProtocol_handleGets
int MQTTProtocol_handleGets(void* pack, int sock)
{
Getack* getack = (Getack*)pack;
Clients* client = NULL;
char* clientid = NULL;
int rc = TCPSOCKET_COMPLETE;
FUNC_ENTRY;
// printf("------>%s, %s, %d\n", __func__, getack->ack_payload.ret_string, getack->ack_payload.ext_cmd);
client = (Clients*)(ListFindItem(bstate->clients, &sock, clientSocketCompare)->content);
clientid = client->clientID;
// Log(LOG_PROTOCOL, 11, NULL, sock, clientid, getack->msgId, get->header.bits.qos,
// getack->header.bits.retain, min(20, getack->ext_payloadlen), get->ext_payload);
/* here we needn't process some just like publish. only to parse ext ack, get one callback. */
#if 0
if (get->header.bits.qos == 0)
Protocol_processPublication(get, client);
else if (get->header.bits.qos == 1)
{
/* send puback before processing the publications because a lot of return publications could fill up the socket buffer */
rc = MQTTPacket_send_puback(publish->msgId, &client->net, client->clientID);
/* if we get a socket error from sending the puback, should we ignore the publication? */
Protocol_processPublication(publish, client);
}
else if (publish->header.bits.qos == 2)
{
/* store publication in inbound list */
int len;
ListElement* listElem = NULL;
Messages* m = malloc(sizeof(Messages));
Publications* p = MQTTProtocol_storePublication(publish, &len);
m->publish = p;
m->msgid = publish->msgId;
m->qos = publish->header.bits.qos;
m->retain = publish->header.bits.retain;
m->nextMessageType = PUBREL;
if ( ( listElem = ListFindItem(client->inboundMsgs, &(m->msgid), messageIDCompare) ) != NULL )
{ /* discard queued publication with same msgID that the current incoming message */
Messages* msg = (Messages*)(listElem->content);
MQTTProtocol_removePublication(msg->publish);
ListInsert(client->inboundMsgs, m, sizeof(Messages) + len, listElem);
ListRemove(client->inboundMsgs, msg);
} else
ListAppend(client->inboundMsgs, m, sizeof(Messages) + len);
rc = MQTTPacket_send_pubrec(publish->msgId, &client->net, client->clientID);
publish->topic = NULL;
}
MQTTPacket_freePublish(publish);
#endif
MQTTPacket_freeGet(getack);
FUNC_EXIT_RC(rc);
return rc;
}
开发者ID:is00hcw,项目名称:yunba-c-sdk,代码行数:55,代码来源:MQTTProtocolClient.c
示例20: main
void main()
{
SqList La, Lb, Lc;
int j;
InitList(La);
for ( j = 1; j <= 5; j++ )
ListInsert(La, j, j);
printf("La = ");
ListTraverse(La, print1);
InitList(Lb);
for ( j = 1; j <= 5; j++ )
ListInsert(Lb, j, j*2);
printf("Lb = ");
ListTraverse(Lb, print1);
MergeList(La, Lb, Lc);
printf("Lc = ");
ListTraverse(Lc, print1);
}
开发者ID:kobemiller,项目名称:DataStructure,代码行数:20,代码来源:algo2-4.cpp
注:本文中的ListInsert函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论