// // avltest.h --- test program for avl maps and sets // // Copyright (C) 1996 Limit Point Systems, Inc. // // Author: Curtis Janssen // Maintainer: LPS // // This file is part of the SC Toolkit. // // The SC Toolkit is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // The SC Toolkit is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with the SC Toolkit; see the file COPYING.LIB. If not, write to // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. // // The U.S. Government is granted a limited license as per AL 91-7. // #include #include #include #ifdef HAVE_CONFIG_H #include #endif #include #include #include using namespace std; using sc::AVLMap; using sc::AVLSet; using sc::EAVLMMap; using sc::EAVLMMapNode; using sc::compare; class Data { public: EAVLMMapNode map1; EAVLMMapNode map2; public: Data(int k1, int k2 = 0): map1(k1), map2(k2) {}; void print(int indent = 0); void change1(int val) { map1.key = val; } }; void Data::print(int indent) { for (int i=0; i& map, Data** data, int n) { for (int i=0; iprint(); cout << endl; #endif map.remove(data[i]); Nr++; #if 0 map.print2(); #endif map.check(); map.clear_without_delete(); } } void rantest(EAVLMMap&map1, Data** data, int n) { int i; for (i=0; ichange1(random()); map1.insert(d); Ni++; } map1.check(); for (i=0; i map1(&Data::map1); Data* data[maxkey][maxkey]; Data* currentdata[maxkey]; for (i=0; i emap(&Data::map1); for (i=0; i::iterator im=emap.begin(); im!=emap.end(); im++) { cout << " " << im.key() << " " << im->map2.key << endl; } cout << "map:" << endl; AVLMap icmap; for (i=0; i::iterator ic=icmap.begin(); ic!=icmap.end(); ic++) { cout << " " << ic.key() << " " << ic.data() << endl; } cout << "set:" << endl; AVLSet iset; for (i=0; i<10; i++) { iset.insert(i); } if (iset.length() != 10) abort(); iset.remove(100); if (iset.length() != 10) abort(); if (!iset.contains(3)) abort(); iset.remove(3); if (iset.contains(3)) abort(); if (iset.length() != 9) abort(); for (i=0; i<10; i++) iset.remove(i); if (iset.length() != 0) abort(); if (iset.contains(3)) abort(); if (iset.length() != 0) abort(); iset.clear(); for (i=0; i::iterator is=iset.begin(); is!=iset.end(); is++) { cout << " " << is.key() << endl; } #if TEST1 cout << "=================================================" << endl; max = 1; for (i=0; i