⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventspace.h

📁 Amis - A maximum entropy estimator 一个最大熵模型统计工具
💻 H
字号:
////////////////////////////////////////////////////////////////////////////  Copyright (c) 2000, Yusuke Miyao///  You may distribute under the terms of the Artistic License.//////  <id>$Id: EventSpace.h,v 1.3 2003/05/11 18:12:09 yusuke Exp $</id>///  <collection>Maximum Entropy Estimator</collection>///  <name>EventSpace.h</name>///  <overview>A set of events in ME Model</overview>/////////////////////////////////////////////////////////////////////////#ifndef Amis_EventSpace_h_#define Amis_EventSpace_h_#include <amis/configure.h>#include <amis/EventSpaceBase.h>#include <amis/VectorOnFile.h>#include <vector>AMIS_NAMESPACE_BEGINtemplate< class Event, bool Onfile>class EventStorage{public:  EventStorage()   {    AMIS_ABORT( "EventStorage not implemented." );  }    void push_back( const Event& e ) {    AMIS_ABORT( "EventStorage::push_back not implemented." );  }  };template< class Event >class EventStorage<Event, false> : public std::vector<Event>{public:  EventStorage( void* any ) { }  };template< class Event >class EventStorage<Event, true> : public VectorOnFile<Event>{  EventStorage( void* any ) : VectorOnFile<Event>( (objstream*)any ) { }  /// dangerous cast};///////////////////////////////////////////////////////////////////////// <classdef>/// <name>EventSpace</name>/// <overview>A base class for implementation of a set of events</overview>/// <desc>A set of all possible events in the task</desc>/// <body>template < class Feature, class Event >class EventSpace : public EventSpaceBase {public:  typedef Feature FeatureType;  typedef Event EventType;  typedef typename Feature::FeatureFreq FeatureFreq;private:  FeatureFreq max_feature_count;public:  EventSpace( void ) {    max_feature_count = Feature::MIN_FEATURE_FREQ;  }  virtual ~EventSpace() {}protected:  virtual void push( Event& event ) = 0;  /// Add a new event to an event listpublic:  virtual const Event& operator[]( int i ) const = 0;  /// Get the i-th eventprotected:  void updateMaxFeatureCount( FeatureFreq m ) {    if ( m > max_feature_count ) max_feature_count = m;  }  /// Update a maximum value of feature counts if neededpublic:  FeatureFreq maxFeatureCount( void ) const {    return max_feature_count;  }  /// Get a maximum value of feature countspublic:  virtual void addEvent( Event& e ) {    if ( ! e.isValid() ) throw IllegalEventError( "Invalid event found" );    incNumEvents();    incNumFeatureLists( e.numFeatureList() );    incSumEventCount( e.eventFrequency() );    updateMaxFeatureCount( e.maxFeatureCount() );    push( e );  }  /// Add a new event to the event space};AMIS_NAMESPACE_END/// </body>/// </classdef>#endif // EventSpace_h_// end of EventSpace.h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -