|
|
1.1 root 1: // ************************************************************************
2: //
1.1.1.2 ! root 3: // Microsoft Developer Support
! 4: // Copyright (c) 1992 Microsoft Corporation
! 5: //
! 6: // ************************************************************************
! 7: // HEADER : LinkList.H
! 8: // PURPOSE : Provide a generalized sorted double linked list package
! 9: // FUNCTIONS :
1.1 root 10: // InitList - initialize/clear list
11: // CreateNode - allocate a new node that can be put into list
12: // InsertNode - insert a new node into the list
13: // DeleteCurrentNode - remove a node from the list
14: // GetNextNode - get the next (right) node from the CurrentNode
15: // GetPreviousNode - get the previous (left) node from the
16: // CurrentNode
17: // GetNode - get nth Occurence of a node that matches a
18: // key(s)
19: // GetListError - get the error value
20: //
21: // COMMENTS: The application must serialize access to the linked list
22: //
23: // Format of the Ordering and Matching functions is as follows:
24: //
25: // int OrderFunc( PNODE pNodeOne, PNODE pNodeTwo )
26: // {
27: // if( (pNodeOne->NodeData).Key < (pNodeTwo->NodeData).Key )
28: // return( LEFT_OF );
29: // if( (pNodeOne->NodeData).Key == (pNodeTwo->NodeData).Key )
30: // return( MATCH );
31: // if( (pNodeOne->NodeData).Key > (pNodeTwo->NodeData).Key )
32: // return( RIGHT_OF );
33: // }
34: //
35: // ************************************************************************
1.1.1.2 ! root 36: #ifndef LINKLIST_H
1.1 root 37:
1.1.1.2 ! root 38: #define LINKLIST_H
1.1 root 39:
1.1.1.2 ! root 40: #include <WinDef.H> // for DWORD definition only
1.1 root 41:
1.1.1.2 ! root 42: #define NO_ERROR_FOUND 1
! 43: #define NO_FREE_MEM_ERROR -1
! 44: #define NO_NODE_ERROR -2
! 45: #define NO_MATCH_ERROR -3
! 46: #define NO_NEXT_NODE_ERROR -4
! 47: #define NO_PREV_NODE_ERROR -5
! 48:
! 49: #define DEREFERENCE_NULL_ERROR -99
! 50:
! 51: #define LEFT_OF -1
! 52: #define MATCH 0
! 53: #define OVERWRITE 0
! 54: #define RIGHT_OF 1
! 55:
! 56: // ************************************************************************
! 57: // the NODE_DATA type should be modified to suit needs
! 58:
! 59: typedef struct NODE_DATA_STRUCT {
! 60: DWORD dwThreadId;
! 61: HANDLE hThread;
! 62: } NODE_DATA;
! 63:
! 64: //* End of custom NODE_DATA definition
! 65: // ************************************************************************
! 66:
! 67: typedef struct NODE_STRUCT* PNODE;
! 68:
! 69: //-- definition of a node
! 70: typedef struct NODE_STRUCT {
! 71: NODE_DATA NodeData;
! 72: PNODE pLeftLink;
! 73: PNODE pRightLink;
! 74: } NODE;
! 75:
! 76: //-- definition of a list
! 77: typedef struct LIST_STRUCT* PLIST;
! 78:
! 79: typedef struct LIST_STRUCT {
! 80: int ListError;
! 81: PNODE pFirstNode;
! 82: PNODE pCurrentNode;
! 83: PNODE pLastNode;
! 84: int (*OrderFunction)(PNODE, PNODE);
! 85: } LIST;
! 86:
! 87: //-- prototypes
! 88: int GetListError( PLIST pList );
! 89: int InitList( PLIST pList, int (*OrderingFunction)( PNODE pNodeOne, PNODE pNodeTwo ) );
! 90: int CreateNode( PLIST pList, PNODE* pNewNode );
! 91: int InsertNode( PLIST pList, PNODE pNewNode );
! 92: int DestroyNode( PNODE pNode );
! 93: int DeleteCurrentNode( PLIST pList );
! 94: int GetNextNode( PLIST pList, PNODE* ppNode );
! 95: int GetPreviousNode( PLIST pList, PNODE* ppNode );
! 96: int GetNode( PLIST pList, PNODE* pKeyNode,
! 97: int (*MatchingFunction)( PNODE pNodeOne, PNODE pNodeTwo ),
! 98: int Occurence );
1.1 root 99:
1.1.1.2 ! root 100: #endif // LINKLIST_H
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.