Ignore:
Timestamp:
Dec 16, 2000, 10:09:53 PM (25 years ago)
Author:
umoeller
Message:

Miscellanous updates.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/linklist.c

    r14 r17  
    353353 *      The item data can be queried from the node
    354354 *      as follows:
     355 *
    355356 +          PLINKLIST pll = lstCreate();
    356357 +          ...  // add items here
     
    359360 *
    360361 *      You can iterate over the whole list like this:
     362 *
    361363 +          PLISTNODE pNode = lstQueryFirstNode(pll);
    362364 +          while (pNode)
     
    425427 */
    426428
    427 PLISTNODE lstNodeFromItem(PLINKLIST pList, void* pItemData)
     429PLISTNODE lstNodeFromItem(PLINKLIST pList,
     430                          void* pItemData)
    428431{
    429432    PLISTNODE pNode = 0,
     
    465468 */
    466469
    467 void* lstItemFromIndex(PLINKLIST pList, unsigned long ulIndex)
     470void* lstItemFromIndex(PLINKLIST pList,
     471                       unsigned long ulIndex)
    468472{
    469473    PLISTNODE pNode = lstNodeFromIndex(pList, ulIndex);
     
    472476    else
    473477        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
     494unsigned 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);
    474512}
    475513
Note: See TracChangeset for help on using the changeset viewer.