📄 arstring.h
字号:
// ARString.h: interface for the ARString class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_ARSTRING_H__1A30E30A_CC69_43C8_8286_AC23508B9EA2__INCLUDED_)
#define AFX_ARSTRING_H__1A30E30A_CC69_43C8_8286_AC23508B9EA2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include "ItemSet.h"
#include "Taxonomy.h"
#include "Parameters.h"
class ARString
{
friend class StringSet;
int nitems; // number of items
int *items; // list of the items
// float *rval; // random value (used to get random ordering of the items)
// int *ritems; // randomly chosen items
float prob; // probability that this string is chosen
float conf; // probability that this string is corrrupted
// void shuffle(void); // shuffles items in string
public:
ARString(int nitems);
~ARString(void);
void display(ofstream &fp, int prob_comp = 1);
void display(ofstream &fp, StringSet &lits, int prob_comp = 1);
// prob is multiplied by prob_comp before being writeed
int size(void) { return nitems;}
int item(int n) { return items[n];} // return nth item of the string
float conf_lvl(void) { return conf; }
void set_size(int newsize) { nitems = newsize;}
void set_item(int n, int itm) { items[n] = itm;}
void set_conf_lvl(float newconf) { conf = newconf; }
// void shuffle(int k); // allows selection of k random items from the string
// int rand_item(int n) { return ritems[n];} // works with shuffle
};
typedef ARString *StringP;
class StringSet
{
friend class StringSetIter;
private:
ItemSet *items;
Taxonomy *tax;
int npats; // number of patterns
StringP *pat; // array of patterns
StringP answer;
float *cum_prob; // cumulative probabilities of patterns
StringP specialize(int i); // specializes pattern #i
public:
StringSet(int nitems, // number of items
PatternPar par, // npats, patlen, corr, conf & conf_var
Taxonomy *tax = NULL, // taxonomy (optional)
float rept = 0, // repetition-level
float rept_lvl = 0.2 // variation in repetition-level
);
~StringSet();
void display(ofstream &fp); // for large itemsets
void display(ofstream &fp, StringSet &lit); // for sequences
StringP get_pat(int i); // returns pattern #i
};
class StringSetIter
{
private:
UniformDist rand;
StringSet *strset;
int last_pat; // if -ve, unget_pat() was called
public:
StringSetIter(StringSet &str_set) : strset(&str_set), last_pat(0) {};
StringP get_pat(void); // returns a random pattern
void unget_pat(void); // the last pattern is put back in the sequence
};
#endif // !defined(AFX_ARSTRING_H__1A30E30A_CC69_43C8_8286_AC23508B9EA2__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -