ScummVM API documentation
u6_llist.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NUVIE_MISC_U6_LIST_H
23 #define NUVIE_MISC_U6_LIST_H
24 
25 namespace Ultima {
26 namespace Nuvie {
27 
28 #define U6LLIST_FREE_DATA true
29 
30 struct U6Link {
31  U6Link *next;
32  U6Link *prev;
33  void *data;
34  uint8 ref_count;
35  U6Link() {
36  next = nullptr;
37  prev = nullptr;
38  data = nullptr;
39  ref_count = 1;
40  }
41 };
42 
43 void retainU6Link(U6Link *link);
44 void releaseU6Link(U6Link *link);
45 
46 class U6LList {
47  U6Link *head;
48  U6Link *tail;
49 
50 public:
51 
52  U6LList();
53  ~U6LList();
54 
55  bool add(void *data);
56  bool addAtPos(uint32 pos, void *data);
57 
58  uint32 findPos(void *data);
59  bool replace(void *old_data, void *new_data);
60 
61  bool remove(void *data);
62  bool removeAll();
63 
64  uint32 count() const;
65 
66  U6Link *start();
67  U6Link *end();
68  const U6Link *start() const;
69  const U6Link *end() const;
70 
71  U6Link *gotoPos(uint32 pos);
72 };
73 
74 } // End of namespace Nuvie
75 } // End of namespace Ultima
76 
77 #endif
Definition: detection.h:27
void replace(It begin, It end, const Dat &original, const Dat &replaced)
Definition: algorithm.h:448
Definition: u6_llist.h:46