📄 classinfo.h
字号:
#ifndef CLASS_TABLE_H#define CLASS_TABLE_H#include "dataTab.h"#define MAX_HASH_SIZE 101class ClassInfo {public: Description des; int count; int label; // Standardised class label, define as integer // Range from 0..N-1 for N classes ClassInfo *next; // Constructor ClassInfo(Description d, int lbl) { des = d; count = 1; next = NULL; label = lbl;#ifdef DBG cout << "ClassInfo Constructor: ";#endif } // increment the count void inc() { count ++; } // return the count int getCount() { return count; } // return the label int getLabel() { return label; } // return the actual description Description getDescription() { return des; } // for debug, print the values void print(int n_Inst);};class ClassInfoTable { int n_Inst; // Number of different instances int n_Classes; // Number of different classes ClassInfo *table[MAX_HASH_SIZE]; // a hash tablepublic: // Constructor ClassInfoTable(SupervisedDataTable &tbl); // return NULL if the Description is not found in the hash // table, otherwise return the pointer ClassInfo *searchInfo(int hashVal, Description v); int numOfClasses() { return n_Classes; } int numOfInstances() { return n_Inst; } void cleanHashTable(); int hash(Description d) { return (int)d % MAX_HASH_SIZE; } // return the class label of the class description int classLabel(Description cd); // return the class count of the class description int getCount(Description d); // return the pointer of that row in the hash table ClassInfo *getRow(int r) { return table[r]; } void print();};// class ClassSummary gives a summary of the ClassInfoTable// ojbect, by eliminating the hash table and building up// another "compact" table, such that the searching of the// result will be constant.class ClassSummary {public: int n_Classes; // the number of classes of the whole table int *count; // head pointer of the count of each class Description *table; // this table will consist of distinct values int n_Instances; // the number of instances // constructor ClassSummary(ClassInfoTable &cTbl); void printClassSummary(); int numOfClasses() { return n_Classes; } // each item in "table" has a count and description // component, such that when given the label which ranges // from 0 - > n_Classes-1, corresponding count and // description could be found int getCount(int label) { return count[label]; } Description getDescription(int label) { return table[label]; } Description getMaxClassValue();};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -