zoukankan      html  css  js  c++  java
  • 引入缓冲池技术

    核心代码,引入缓冲池技术

    class CTechnique

    {

    private:

    //1、定义缓冲池

         double   *    m_pdCache1;

         double   *    m_pdCache2;

         double   *    m_pdCache3;

         double   *    m_pdCache4;

         double   *    m_pdCache5;

    }

    CTechnique::CTechnique( CKData * pKData )

    {

    //2、初始化缓冲池

         m_pdCache1         =    NULL;

         m_pdCache2         =    NULL;

         m_pdCache3         =    NULL;

         m_pdCache4         =    NULL;

         m_pdCache5         =    NULL;

    }

    void CTechnique::Clear( )

    {

    //3、清空缓冲池

         if( m_pdCache1 )

             delete   []   m_pdCache1;

         if( m_pdCache2 )

             delete   []   m_pdCache2;

         if( m_pdCache3 )

             delete   []   m_pdCache3;

         if( m_pdCache4 )

             delete   []   m_pdCache4;

         if( m_pdCache5 )

             delete   []   m_pdCache5;

    }

    // 将计算好的数据保存至缓冲区

    BOOL CTechnique::StoreToCache( int nIndex, double * pValue1, double *pValue2, double *pValue3, double * pValue4, double * pValue5 )

    {

    //4、从缓冲池中存数据

         if( pValue1 && m_pdCache1 && m_pbHasCache1 )

         {

             m_pdCache1[nIndex-m_nIndexStart]     =    *pValue1;

         }

         if( pValue2 && m_pdCache2 && m_pbHasCache2 )

         {

             m_pdCache2[nIndex-m_nIndexStart]     =    *pValue2;

         }

         if( pValue3 && m_pdCache3 && m_pbHasCache3 )

         {

             m_pdCache3[nIndex-m_nIndexStart]     =    *pValue3;

         }

         if( pValue4 && m_pdCache4 && m_pbHasCache4 )

         {

             m_pdCache4[nIndex-m_nIndexStart]     =    *pValue4;

         }

         if( pValue5 && m_pdCache5 && m_pbHasCache5 )

         {

             m_pdCache5[nIndex-m_nIndexStart]     =    *pValue5;

         }

    }

    BOOL CTechnique::LoadFromCache( int nIndex, double * pValue1, double * pValue2, double * pValue3, double * pValue4, double * pValue5 )

    {

    //4、从缓冲池中取数据

         if( pValue1 )

             *pValue1 =    m_pdCache1[nIndex-m_nIndexStart];

         if( pValue2 )

             *pValue2 =    m_pdCache2[nIndex-m_nIndexStart];

         if( pValue3 )

             *pValue3 =    m_pdCache3[nIndex-m_nIndexStart];

         if( pValue4 )

             *pValue4 =    m_pdCache4[nIndex-m_nIndexStart];

         if( pValue5 )

             *pValue5 =    m_pdCache5[nIndex-m_nIndexStart];

    }

  • 相关阅读:
    CentOS/RedHat安装Python3
    Hash校验工具、MD5 SHA1 SHA256命令行工具
    centos如何安装Python3
    iOS之UI--涂鸦画板实例
    iOS之UI--Quartz2D的入门应用-- 重绘下载圆形进度条
    Eclipse导入项目: No projects are found to import
    在MAC平台下使用Eclipse出现了中文乱码
    C语言错误之--初始值(低级错误)
    iOS开发之duplicate symbols for architecture x86_64错误
    C语言的传值与传址调用
  • 原文地址:https://www.cnblogs.com/boobuy/p/2864779.html
Copyright © 2011-2022 走看看