author | wimpie <wimpie> | 2004-04-09 18:04:30 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-09 18:04:30 (UTC) |
commit | 028717962deec0c2ff0e382221cbc2242393b79e (patch) (unidiff) | |
tree | a5f00a3b3d229f838b6e40e34ca12f248b317813 /inputmethods/dasher/AlphabetMap.h | |
parent | d17b9f7b64e004dcc301866f8122171218553b42 (diff) | |
download | opie-028717962deec0c2ff0e382221cbc2242393b79e.zip opie-028717962deec0c2ff0e382221cbc2242393b79e.tar.gz opie-028717962deec0c2ff0e382221cbc2242393b79e.tar.bz2 |
Removed warnings about initialization sequence in constructores
and unused variables and arguments
Diffstat (limited to 'inputmethods/dasher/AlphabetMap.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/dasher/AlphabetMap.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/inputmethods/dasher/AlphabetMap.h b/inputmethods/dasher/AlphabetMap.h index 3aac1f5..62f20d9 100644 --- a/inputmethods/dasher/AlphabetMap.h +++ b/inputmethods/dasher/AlphabetMap.h | |||
@@ -23,89 +23,89 @@ The result is this: | |||
23 | *************************************************** | 23 | *************************************************** |
24 | very much thrown together to get Dasher out ASAP. | 24 | very much thrown together to get Dasher out ASAP. |
25 | *************************************************** | 25 | *************************************************** |
26 | It is deliberately not like an STL container. | 26 | It is deliberately not like an STL container. |
27 | However, as it has a tiny interface, it should still be easy to replace. | 27 | However, as it has a tiny interface, it should still be easy to replace. |
28 | Sorry if this seems really unprofressional. | 28 | Sorry if this seems really unprofressional. |
29 | 29 | ||
30 | Replacing it might be a good idea. On the other hand it could be customised | 30 | Replacing it might be a good idea. On the other hand it could be customised |
31 | to the needs of the alphabet, so that it works faster. For example, | 31 | to the needs of the alphabet, so that it works faster. For example, |
32 | currently if I have a string "asdf", it might be that "a" is checked | 32 | currently if I have a string "asdf", it might be that "a" is checked |
33 | then "as" is checked then "asd" is checked. I shouldn't need to keep | 33 | then "as" is checked then "asd" is checked. I shouldn't need to keep |
34 | rehashing the leading characters. I plan to fix that here. Doing so with | 34 | rehashing the leading characters. I plan to fix that here. Doing so with |
35 | a standard hash_map would be hard. | 35 | a standard hash_map would be hard. |
36 | 36 | ||
37 | 37 | ||
38 | Usage: | 38 | Usage: |
39 | alphabet_map MyMap(NumberOfEntriesWeExpect); // Can omit NumberOfEntriesWeExpect | 39 | alphabet_map MyMap(NumberOfEntriesWeExpect); // Can omit NumberOfEntriesWeExpect |
40 | MyMap.add("asdf", 15); | 40 | MyMap.add("asdf", 15); |
41 | symbol i = MyMap.get("asdf") // i=15 | 41 | symbol i = MyMap.get("asdf") // i=15 |
42 | symbol j = MyMap.get("fdsa") // j=0 | 42 | symbol j = MyMap.get("fdsa") // j=0 |
43 | 43 | ||
44 | You can't remove items once they are added as Dasher has no need for that. | 44 | You can't remove items once they are added as Dasher has no need for that. |
45 | 45 | ||
46 | IAM 08/2002 | 46 | IAM 08/2002 |
47 | */ | 47 | */ |
48 | 48 | ||
49 | #ifndef __AlphabetMap_h__ | 49 | #ifndef __AlphabetMap_h__ |
50 | #define __AlphabetMap_h__ | 50 | #define __AlphabetMap_h__ |
51 | 51 | ||
52 | #include "MSVC_Unannoy.h" | 52 | #include "MSVC_Unannoy.h" |
53 | #include <vector> | 53 | #include <vector> |
54 | #include <string> | 54 | #include <string> |
55 | 55 | ||
56 | #include "DasherTypes.h" | 56 | #include "DasherTypes.h" |
57 | 57 | ||
58 | namespace Dasher {class alphabet_map;} | 58 | namespace Dasher {class alphabet_map;} |
59 | class Dasher::alphabet_map | 59 | class Dasher::alphabet_map |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | alphabet_map(uint InitialTableSize=255); | 62 | alphabet_map(uint InitialTableSize=255); |
63 | void Add(const std::string& Key, symbol Value); | 63 | void Add(const std::string& Key, symbol Value); |
64 | symbol Get(const std::string& Key, bool* KeyIsPrefix=0) const; | 64 | symbol Get(const std::string& Key, bool* KeyIsPrefix=0) const; |
65 | 65 | ||
66 | private: | 66 | private: |
67 | class Entry | 67 | class Entry |
68 | { | 68 | { |
69 | public: | 69 | public: |
70 | Entry(std::string Key, symbol Symbol, Entry* Next) | 70 | Entry(std::string Key, symbol Symbol, Entry* Next) |
71 | : Key(Key), Symbol(Symbol), Next(Next), KeyIsPrefix(false) {} | 71 | : Key(Key), KeyIsPrefix(false), Symbol(Symbol), Next(Next) {} |
72 | 72 | ||
73 | std::string Key; | 73 | std::string Key; |
74 | bool KeyIsPrefix; | 74 | bool KeyIsPrefix; |
75 | symbol Symbol; | 75 | symbol Symbol; |
76 | Entry* Next; | 76 | Entry* Next; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | void RecursiveAdd(const std::string& Key, symbol Value, bool PrefixFlag); | 79 | void RecursiveAdd(const std::string& Key, symbol Value, bool PrefixFlag); |
80 | 80 | ||
81 | // A standard hash -- could try and research something specific. | 81 | // A standard hash -- could try and research something specific. |
82 | inline uint Hash(const std::string& Input) const { | 82 | inline uint Hash(const std::string& Input) const { |
83 | uint Result = 0; | 83 | uint Result = 0; |
84 | 84 | ||
85 | typedef std::string::const_iterator CI; | 85 | typedef std::string::const_iterator CI; |
86 | CI Cur = Input.begin(); | 86 | CI Cur = Input.begin(); |
87 | CI end = Input.end(); | 87 | CI end = Input.end(); |
88 | 88 | ||
89 | while (Cur!=end) Result = (Result<<1)^*Cur++; | 89 | while (Cur!=end) Result = (Result<<1)^*Cur++; |
90 | Result %= HashTable.size(); | 90 | Result %= HashTable.size(); |
91 | 91 | ||
92 | return Result; | 92 | return Result; |
93 | /* | 93 | /* |
94 | if (Input.size()==1) // Speedup for ASCII text | 94 | if (Input.size()==1) // Speedup for ASCII text |
95 | return Input[0]; | 95 | return Input[0]; |
96 | 96 | ||
97 | for (int i=0; i<Input.size(); i++) | 97 | for (int i=0; i<Input.size(); i++) |
98 | Result = (Result<<1)^Input[i]; | 98 | Result = (Result<<1)^Input[i]; |
99 | 99 | ||
100 | 100 | ||
101 | return Result%HashTable.size(); | 101 | return Result%HashTable.size(); |
102 | */ | 102 | */ |
103 | } | 103 | } |
104 | 104 | ||
105 | std::vector<Entry> Entries; | 105 | std::vector<Entry> Entries; |
106 | std::vector<Entry*> HashTable; | 106 | std::vector<Entry*> HashTable; |
107 | const symbol Undefined; | 107 | const symbol Undefined; |
108 | }; | 108 | }; |
109 | 109 | ||
110 | 110 | ||
111 | #endif /* #ifndef __AlphabetMap_h__ */ | 111 | #endif /* #ifndef __AlphabetMap_h__ */ |