Line | |
---|
1 | #ifndef _COUNTEDDICTIONARY_H_ |
---|
2 | #define _COUNTEDDICTIONARY_H_ |
---|
3 | |
---|
4 | template <class Dict> |
---|
5 | class CountedDictionary : public Dict { |
---|
6 | public: |
---|
7 | class Entry : public Dict::Entry {}; |
---|
8 | |
---|
9 | __forceinline CountedDictionary (void) |
---|
10 | : num (0) |
---|
11 | {} |
---|
12 | |
---|
13 | __forceinline void clear (void) { |
---|
14 | num = 0; |
---|
15 | Dict::clear(); |
---|
16 | } |
---|
17 | |
---|
18 | __forceinline Entry * get (void) { |
---|
19 | Entry * e = (Entry *) Dict::get(); |
---|
20 | if (e) { |
---|
21 | --num; |
---|
22 | } |
---|
23 | return e; |
---|
24 | } |
---|
25 | |
---|
26 | __forceinline Entry * remove (void) { |
---|
27 | Entry * e = (Entry *) Dict::remove(); |
---|
28 | if (e) { |
---|
29 | --num; |
---|
30 | } |
---|
31 | return e; |
---|
32 | } |
---|
33 | |
---|
34 | __forceinline void insert (Entry * e) { |
---|
35 | Dict::insert (e); |
---|
36 | ++num; |
---|
37 | } |
---|
38 | |
---|
39 | __forceinline int getNumber (void) const { |
---|
40 | return num; |
---|
41 | } |
---|
42 | |
---|
43 | private: |
---|
44 | int num; |
---|
45 | }; |
---|
46 | |
---|
47 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.