[Lemon-commits] [lemon_svn] klao: r490 - hugo/trunk/src/work/klao
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:39:43 CET 2006
Author: klao
Date: Wed Apr 21 18:09:42 2004
New Revision: 490
Modified:
hugo/trunk/src/work/klao/iter_map.h
hugo/trunk/src/work/klao/iter_map_test.cc
Log:
IterableMap: no range checking, no warning :)
Modified: hugo/trunk/src/work/klao/iter_map.h
==============================================================================
--- hugo/trunk/src/work/klao/iter_map.h (original)
+++ hugo/trunk/src/work/klao/iter_map.h Wed Apr 21 18:09:42 2004
@@ -55,6 +55,7 @@
--m;
half_swap(a, bounds[m]++);
}
+ // FIXME: range check ide?
while(m < n) {
half_swap(a, --bounds[m]);
++m;
@@ -79,39 +80,31 @@
}
void set(const KeyType& k, Val n) {
- // FIXME: n < N ???
+ // FIXME: range check?
size_t a = base[k];
- if(a < bounds[N-1] && n < N) {
+ if(a < bounds[N-1]) {
base.set(k, move(a, find(a), n));
}
+ else {
+ insert(k, n);
+ }
}
void insert(const KeyType& k, Val n) {
- if(n < N) {
- data.push_back(k);
- base.set(k, move(bounds[N-1]++, N-1, n));
- }
+ data.push_back(k);
+ base.set(k, move(bounds[N-1]++, N-1, n));
}
iterator begin(Val n) const {
- if(n < N)
- return data.begin() + (n ? bounds[n-1] : 0);
- else
- return data.end();
+ return data.begin() + (n ? bounds[n-1] : 0);
}
iterator end(Val n) const {
- if(n < N)
- return data.begin() + bounds[n];
- else
- return data.end();
+ return data.begin() + bounds[n];
}
size_t size(Val n) const {
- if(n < N)
- return bounds[n] - (n ? bounds[n-1] : 0);
- else
- return 0;
+ return bounds[n] - (n ? bounds[n-1] : 0);
}
size_t size() const {
Modified: hugo/trunk/src/work/klao/iter_map_test.cc
==============================================================================
--- hugo/trunk/src/work/klao/iter_map_test.cc (original)
+++ hugo/trunk/src/work/klao/iter_map_test.cc Wed Apr 21 18:09:42 2004
@@ -119,10 +119,10 @@
}
{
- cout << "Testing the IterableBoolMap...\n";
+ cout << "\n\n\nTesting the IterableBoolMap...\n";
BaseMap base(344);
- TestBoolMap test(base);
+ TestBoolMap test(base,true);
print(test,2);
@@ -157,54 +157,27 @@
cout << " 11: " << test[11] << endl;
cout << " 42: " << test[42] << endl;
- cout << "Inserting 21 to class 1...\n";
- test.insert(21,1);
- print(test,2);
-
- cout << "Inserting 20 to class 1...\n";
- test.insert(20,0);
- print(test,2);
-
- cout << "Testing some map values:\n";
- cout << " 12: " << test[12] << endl;
- cout << " 22: " << test[22] << endl;
- cout << " 10: " << test[10] << endl;
- cout << " 20: " << test[20] << endl;
- cout << " 11: " << test[11] << endl;
- cout << " 21: " << test[21] << endl;
- cout << " 42: " << test[42] << endl;
-
- cout << "Setting 20 to class 2...\n";
- test.set(20,2);
+ cout << "Setting 10 to class true...\n";
+ test.set(10,true);
print(test,2);
- cout << "Setting 10 to class 1...\n";
- test.set(10,1);
- print(test,2);
-
- cout << "Setting 11 to class 1...\n";
+ cout << "Setting 11 to class true...\n";
test.set(11,1);
print(test,2);
- cout << "Setting 12 to class 1...\n";
- test.set(12,1);
- print(test,2);
-
- cout << "Setting 21 to class 2...\n";
- test.set(21,2);
+ cout << "Setting 12 to class false...\n";
+ test.set(12,false);
print(test,2);
- cout << "Setting 22 to class 2...\n";
- test.set(22,2);
+ cout << "Setting 22 to class false...\n";
+ test.set(22,false);
print(test,2);
cout << "Testing some map values:\n";
cout << " 12: " << test[12] << endl;
cout << " 22: " << test[22] << endl;
cout << " 10: " << test[10] << endl;
- cout << " 20: " << test[20] << endl;
cout << " 11: " << test[11] << endl;
- cout << " 21: " << test[21] << endl;
cout << " 42: " << test[42] << endl;
}
More information about the Lemon-commits
mailing list