?? tvtest2.c
字號:
/* COPYRIGHT NOTICE This material was developed by Christos Faloutsos and King-Ip Linat the University of Maryland, College Park, Department of Computer Science.Permission is granted to copy this software, to redistribute iton a nonprofit basis, and to use it for any purpose, subject tothe following restrictions and understandings. 1. Any copy made of this software must include this copyright noticein full. 2. All materials developed as a consequence of the use of thissoftware shall duly acknowledge such use, in accordance with the usualstandards of acknowledging credit in academic research. 3. The authors have made no warranty or representation that theoperation of this software will be error-free or suitable for anyapplication, and they are under under no obligation to provide anyservices, by way of maintenance, update, or otherwise. The softwareis an experimental prototype offered on an as-is basis. 4. Redistribution for profit requires the express, written permissionof the authors. */// Author : $Author$// Date : $Date$// Id : $Id$// $Id: indextest.C,v 1.6 1996/04/18 21:50:24 kilin Exp kilin $ #include <iostream.h>#include <fstream.h>#include <assert.h>#include <stdlib.h>#include <String.h>#include "TVdefine.h"#include "TVconstants.h"#include "TVvector.h"#include "TVelement.h"#include "TVrectangle.h"#include "TVsimbuf.h"#include "TVnode.h"#include "TVindexstat.h"#include "TVindexpara.h"#include "TVindex.h"#include "TVutil.h"#include "data.h"extern "C" { char* strcpy(char*, const char*); int strcmp(const char*, const char*);// unsigned int strlen(const char*);}#define DEBUG 1Storage *globstorage;int eletested;TVector GetTVector(DataPoints& dp, int dim = 0){ dim = (dim ? dim : 30); TVector v(dim); for (int i = 0; i < dim; i++) v[i] = dp[i]; return v;}#define TEST_PAGESIZE 1024#define TEST_ACTIVEDIM 2#define TEST_MINFULLPCT 40#define TEST_REINSERTPCT 40#define TEST_PICKBRANCHCOUNT 5#define PHASES 3#define TEST_BUFFERS 10#define TEST_DATA_COUNT 10main(){ // Creat Storage globstorage = new Storage(TEST_PAGESIZE, TEST_BUFFERS); TVTree_Para tpara(TEST_PAGESIZE, TEST_ACTIVEDIM, TEST_MINFULLPCT, TEST_REINSERTPCT, TEST_PICKBRANCHCOUNT); TVTree tv1(tpara, PHASES); ifstream ifile("testnum", ios::in); // Inserting data for (int i = 0; i < TEST_DATA_COUNT; i++) { DataPoints *dp = new DataPoints; // Get a new element ifile >>= *dp; dp->key = i + 1;cout << "Inserting : " << *dp << endl; char *barray = (*dp)(); // convert into byte array tv1.Insert(barray, dp->Size(), GetFeature); // Insert into the tree delete [] barray; } ifile.close(); // Print Tree cout << "Printing the tree : "; tv1.TVTreePrint(cout, PrintData); // Print stats tv1.GatherTreeStats(); tv1.PrintStats(cout); // Searching data ifstream sfile("testnum", ios::in); for (int s = 0; s < TEST_DATA_COUNT / 5; s++) { DataPoints dp; sfile >>= dp; dp.key = s + 1; char **res; // To search for exact matches char *barray = dp(); // convert into byte array int count = tv1.Search(barray, dp.Size(), res, GetKey, GetFeature, Equal); delete [] barray; cout << "Searching " << dp << " : " ; for (int i = 0; i < count; i++) cout << *((int *)(res[i])) << " "; cout << endl; } sfile.close(); // Range search ifstream rfile("testnum", ios::in); for (int s = 0; s < TEST_DATA_COUNT / 5; s++) { DataPoints dp; rfile >>= dp; dp.key = s + 1; char **res; // Range search char *barray = dp(); // convert into byte array int count = tv1.Search(10, barray, dp.Size(), res, GetKey, GetFeature, Distance); delete [] barray; cout << "Searching " << dp << " : " ; for (int i = 0; i < count; i++) cout << *((int *)(res[i])) << " "; cout << endl; } rfile.close();}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -