Changeset 17 for trunk/src/helpers/linklist.c
- Timestamp:
- Dec 16, 2000, 10:09:53 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/linklist.c
r14 r17 353 353 * The item data can be queried from the node 354 354 * as follows: 355 * 355 356 + PLINKLIST pll = lstCreate(); 356 357 + ... // add items here … … 359 360 * 360 361 * You can iterate over the whole list like this: 362 * 361 363 + PLISTNODE pNode = lstQueryFirstNode(pll); 362 364 + while (pNode) … … 425 427 */ 426 428 427 PLISTNODE lstNodeFromItem(PLINKLIST pList, void* pItemData) 429 PLISTNODE lstNodeFromItem(PLINKLIST pList, 430 void* pItemData) 428 431 { 429 432 PLISTNODE pNode = 0, … … 465 468 */ 466 469 467 void* lstItemFromIndex(PLINKLIST pList, unsigned long ulIndex) 470 void* lstItemFromIndex(PLINKLIST pList, 471 unsigned long ulIndex) 468 472 { 469 473 PLISTNODE pNode = lstNodeFromIndex(pList, ulIndex); … … 472 476 else 473 477 return (0); 478 } 479 480 /* 481 *@@ lstIndexFromItem: 482 * returns the index of the list node with 483 * the specified item pointer. The first 484 * node returns 0, the second 1, and so on. 485 * 486 * Returns -1 if not found. 487 * 488 * In the worst case, this function traverses 489 * the whole list. 490 * 491 *@@added V0.9.7 (2000-12-13) [umoeller] 492 */ 493 494 unsigned long lstIndexFromItem(PLINKLIST pList, void *pItemData) 495 { 496 ULONG ulrc = -1, 497 ulIndex = 0; 498 PLISTNODE pNode = lstQueryFirstNode(pList); 499 while (pNode) 500 { 501 if (pNode->pItemData == pItemData) 502 { 503 ulrc = ulIndex; 504 break; 505 } 506 507 pNode = pNode->pNext; 508 ulIndex++; 509 } 510 511 return (ulrc); 474 512 } 475 513
Note:
See TracChangeset
for help on using the changeset viewer.