1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef __GenLinkedList__
19 #define __GenLinkedList__
31 typedef struct GenLinkedList GenLinkedList
;
34 void InitLinkedList( GenLinkedList
*pList
, size_t linkOffset
);
36 void AddToHead( GenLinkedList
*pList
, void *elem
);
37 void AddToTail( GenLinkedList
*pList
, void *elem
);
39 int RemoveFromList( GenLinkedList
*pList
, void *elem
);
41 int ReplaceElem( GenLinkedList
*pList
, void *elemInList
, void *newElem
);
45 struct GenDoubleLinkedList
52 typedef struct GenDoubleLinkedList GenDoubleLinkedList
;
55 void InitDoubleLinkedList( GenDoubleLinkedList
*pList
, size_t fwdLinkOffset
,
56 size_t backLinkOffset
);
58 void DLLAddToHead( GenDoubleLinkedList
*pList
, void *elem
);
60 void DLLRemoveFromList( GenDoubleLinkedList
*pList
, void *elem
);
64 /* A GenLinkedOffsetList is like a GenLinkedList that stores the *Next field as a signed */
65 /* offset from the address of the beginning of the element, rather than as a pointer. */
67 struct GenLinkedOffsetList
73 typedef struct GenLinkedOffsetList GenLinkedOffsetList
;
76 void InitLinkedOffsetList( GenLinkedOffsetList
*pList
, size_t linkOffset
);
78 void *GetHeadPtr( GenLinkedOffsetList
*pList
);
79 void *GetTailPtr( GenLinkedOffsetList
*pList
);
80 void *GetOffsetLink( GenLinkedOffsetList
*pList
, void *elem
);
82 void OffsetAddToHead( GenLinkedOffsetList
*pList
, void *elem
);
83 void OffsetAddToTail( GenLinkedOffsetList
*pList
, void *elem
);
85 int OffsetRemoveFromList( GenLinkedOffsetList
*pList
, void *elem
);
87 int OffsetReplaceElem( GenLinkedOffsetList
*pList
, void *elemInList
, void *newElem
);
90 #endif // __GenLinkedList__