source: trunk/include/cppbase/bs_map.h@ 346

Last change on this file since 346 was 250, checked in by umoeller, 23 years ago

Build updates, moved files from warpin.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1
2/*
3 *@@sourcefile bs_list.h:
4 * replacement for the STL list class template.
5 */
6
7#ifndef BSMAP_INCLUDED
8 #define BSMAP_INCLUDED
9
10 /* ******************************************************************
11 *
12 * Replacement map class
13 *
14 ********************************************************************/
15
16 /*
17 *@@ BSMap:
18 *
19 */
20
21 template <class P, FNTREE_COMPARE *pfnCompare>
22 struct BSMap
23 {
24 TREE *_TreeRoot;
25 LONG _cEntries;
26
27 BSMap()
28 {
29 treeInit(&_TreeRoot, &_cEntries);
30 }
31
32 int inline insert(P p)
33 {
34 return (treeInsert(&_TreeRoot,
35 &_cEntries,
36 (TREE*)p,
37 pfnCompare));
38 }
39
40 P inline first()
41 {
42 return (P)treeFirst(_TreeRoot);
43 }
44
45 P inline next(P p)
46 {
47 return (P)treeNext((TREE*)p);
48 }
49 };
50
51 /*
52 *@@ StringMapEntry:
53 * string map entry for codepaged strings.
54 */
55
56 struct StringMapEntry
57 {
58 TREE _Tree;
59 // ulKey has a const pointer to the strFuncName.c_str()
60 const string _strKey;
61 string _strValue;
62
63 StringMapEntry(const string &strKey,
64 const string &strValue)
65 : _strKey(strKey),
66 _strValue(strValue)
67 {
68 // store PCSZ strKey as the tree key
69 _Tree.ulKey = (ULONG)_strKey.c_str();
70 }
71
72 StringMapEntry(PCSZ pcszKey,
73 PCSZ pcszValue)
74 : _strKey(pcszKey),
75 _strValue(pcszValue)
76 {
77 // store PCSZ strKey as the tree key
78 _Tree.ulKey = (ULONG)_strKey.c_str();
79 }
80 };
81
82 /*
83 *@@ UStringMapEntry:
84 * string map entry for Unicode (UTF-8) strings.
85 *
86 *@@added V0.9.20 (2002-07-03) [umoeller]
87 */
88
89 struct UStringMapEntry
90 {
91 TREE _Tree;
92 // ulKey has a const pointer to the strFuncName.c_str()
93 const ustring _ustrKey;
94 ustring _ustrValue;
95
96 UStringMapEntry(const ustring &ustrKey,
97 const ustring &ustrValue)
98 : _ustrKey(ustrKey),
99 _ustrValue(ustrValue)
100 {
101 // store PCSZ strKey as the tree key
102 _Tree.ulKey = (ULONG)_ustrKey.GetBuffer();
103 }
104 };
105
106#endif
107
108
Note: See TracBrowser for help on using the repository browser.