📄 taxonomy.h
字号:
// Taxonomy.h: interface for the Taxonomy class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TAXONOMY_H__DE28EA1D_2E53_46AC_B4D7_A237F44EC22D__INCLUDED_)
#define AFX_TAXONOMY_H__DE28EA1D_2E53_46AC_B4D7_A237F44EC22D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
class Taxonomy
{
friend class TaxStat;
private:
int nitems; // number of items
int nroots; // number of roots
float depth; // used when assigning probabilities to items
int *par;
int *child_start;
int *child_end;
static const int item_len; // ASCII field-width of item-id
public:
Taxonomy(int nitems, int nroots, float fanout, float depth_ratio);
~Taxonomy(void);
void write(ofstream &fp); // write taxonomy to file
void write_asc(ofstream &fp); // write taxonomy to ASCII file
void display(ofstream &fp); // display taxonomy (for user)
float depth_ratio(void) { return depth; }
int num_roots(void) { return nroots; }
int root(int itm) { return (par[itm] == -1); }
int num_children(int itm) { return child_end[itm] - child_start[itm]; }
int child(int itm, int n) { return child_start[itm]+n; }
// returns the n'th child of itm
int first_child(int itm) { return child_start[itm]; }
int last_child(int itm) { return child_end[itm]-1; }
int parent(int itm) { return par[itm]; } // -1 => no parent
};
#endif // !defined(AFX_TAXONOMY_H__DE28EA1D_2E53_46AC_B4D7_A237F44EC22D__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -