Changeset 362:6c2e8a1f380a in lemon0.x for src/work
 Timestamp:
 04/21/04 18:09:42 (21 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@490
 Location:
 src/work/klao
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

src/work/klao/iter_map.h
r361 r362 56 56 half_swap(a, bounds[m]++); 57 57 } 58 // FIXME: range check ide? 58 59 while(m < n) { 59 60 half_swap(a, bounds[m]); … … 80 81 81 82 void set(const KeyType& k, Val n) { 82 // FIXME: n < N ???83 // FIXME: range check? 83 84 size_t a = base[k]; 84 if(a < bounds[N1] && n < N) {85 if(a < bounds[N1]) { 85 86 base.set(k, move(a, find(a), n)); 87 } 88 else { 89 insert(k, n); 86 90 } 87 91 } 88 92 89 93 void insert(const KeyType& k, Val n) { 90 if(n < N) { 91 data.push_back(k); 92 base.set(k, move(bounds[N1]++, N1, n)); 93 } 94 data.push_back(k); 95 base.set(k, move(bounds[N1]++, N1, n)); 94 96 } 95 97 96 98 iterator begin(Val n) const { 97 if(n < N) 98 return data.begin() + (n ? bounds[n1] : 0); 99 else 100 return data.end(); 99 return data.begin() + (n ? bounds[n1] : 0); 101 100 } 102 101 103 102 iterator end(Val n) const { 104 if(n < N) 105 return data.begin() + bounds[n]; 106 else 107 return data.end(); 103 return data.begin() + bounds[n]; 108 104 } 109 105 110 106 size_t size(Val n) const { 111 if(n < N) 112 return bounds[n]  (n ? bounds[n1] : 0); 113 else 114 return 0; 107 return bounds[n]  (n ? bounds[n1] : 0); 115 108 } 116 109 
src/work/klao/iter_map_test.cc
r361 r362 120 120 121 121 { 122 cout << " Testing the IterableBoolMap...\n";122 cout << "\n\n\nTesting the IterableBoolMap...\n"; 123 123 124 124 BaseMap base(344); 125 TestBoolMap test(base );125 TestBoolMap test(base,true); 126 126 127 127 … … 158 158 cout << " 42: " << test[42] << endl; 159 159 160 cout << "Inserting 21 to class 1...\n"; 161 test.insert(21,1); 162 print(test,2); 163 164 cout << "Inserting 20 to class 1...\n"; 165 test.insert(20,0); 166 print(test,2); 167 168 cout << "Testing some map values:\n"; 169 cout << " 12: " << test[12] << endl; 170 cout << " 22: " << test[22] << endl; 171 cout << " 10: " << test[10] << endl; 172 cout << " 20: " << test[20] << endl; 173 cout << " 11: " << test[11] << endl; 174 cout << " 21: " << test[21] << endl; 175 cout << " 42: " << test[42] << endl; 176 177 cout << "Setting 20 to class 2...\n"; 178 test.set(20,2); 160 cout << "Setting 10 to class true...\n"; 161 test.set(10,true); 179 162 print(test,2); 180 163 181 cout << "Setting 10 to class 1...\n"; 182 test.set(10,1); 183 print(test,2); 184 185 cout << "Setting 11 to class 1...\n"; 164 cout << "Setting 11 to class true...\n"; 186 165 test.set(11,1); 187 166 print(test,2); 188 167 189 cout << "Setting 12 to class 1...\n";190 test.set(12, 1);168 cout << "Setting 12 to class false...\n"; 169 test.set(12,false); 191 170 print(test,2); 192 171 193 cout << "Setting 21 to class 2...\n"; 194 test.set(21,2); 195 print(test,2); 196 197 cout << "Setting 22 to class 2...\n"; 198 test.set(22,2); 172 cout << "Setting 22 to class false...\n"; 173 test.set(22,false); 199 174 print(test,2); 200 175 … … 203 178 cout << " 22: " << test[22] << endl; 204 179 cout << " 10: " << test[10] << endl; 205 cout << " 20: " << test[20] << endl;206 180 cout << " 11: " << test[11] << endl; 207 cout << " 21: " << test[21] << endl;208 181 cout << " 42: " << test[42] << endl; 209 182
Note: See TracChangeset
for help on using the changeset viewer.